Im working on a wolfenstein3d clone and i got recommended to do this in another post, but im confused and im not sure how i use the frame_changed signal to tell the weapons when to refire the weapon
code:
extends CanvasLayer
# Called when the node enters the scene tree for the first time.
func _ready():
$AnimatedSprite2D.animation_finished.connect(_on_AnimatedSprite2d_animation_finished)
$AnimatedSprite2D.play(Global.current_weapon + "_Idle")
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if Global.current_weapon != "Knife" and Global.ammo <= 0:
Global.current_weapon = "Knife"
$AnimatedSprite2D.play("knife_idle")
if Input.is_action_pressed("main_fire_weapon"):
if Global.current_weapon == "Knife":
$AnimatedSprite2D.play("Knife_Stab")
else:
$AnimatedSprite2D.play(Global.current_weapon + "_Fire")
if Global.current_weapon != "Knife":
if Global.ammo > 0:
Global.ammo -= 1
func _on_AnimatedSprite2d_animation_finished():
$AnimatedSprite2D.play(Global.current_weapon + "_Idle")
func _on_animated_sprite_2d_frame_changed():
pass # Replace with function body.