godot 4
when i stop firing the full auto weapon, sometimes, seemingly randomly, it will instead of playing the idle animation, it will hold onto the last frame of the firing frame
heres the firing code (the rest of the code will be below) this problem i have is happening because i added await shit below if Input.is_action_just_released("main_fire_weapon")
but i cant remove that, because it will cause the weapon to be able to be one tapped super fast:
func _process(delta):
if Input.is_action_pressed("main_fire_weapon") and can_fire:
Fire()
await Weapon_Sprite.animation_finished
can_fire = true
if Input.is_action_just_released("main_fire_weapon"):
await Weapon_Sprite.animation_finished
can_fire = true
Weapon_Sprite.play("Idle")
heres the node structure of the weapon:
full code:
extends Node3D
@onready var Weapon_Sprite = $CanvasLayer/Control/WeaponSprite
@onready var Hitscan = $Hitscan.get_children()
var can_fire = true
func _ready():
Weapon_Sprite.play("Idle")
func check_hit():
for ray in Hitscan:
if ray.is_colliding():
if ray.get_collider().is_in_group("Enemy"):
ray.get_collider().take_damage(5)
func _process(delta):
if Input.is_action_pressed("main_fire_weapon") and can_fire:
Fire()
await Weapon_Sprite.animation_finished
can_fire = true
if Input.is_action_just_released("main_fire_weapon"):
await Weapon_Sprite.animation_finished
can_fire = true
Weapon_Sprite.play("Idle")
func Fire():
check_hit()
can_fire = false
$Fire.play()
Weapon_Sprite.play("Fire")