I wanted to delay the projectile until a certain frame in the animation and sync the bullet with that.
I have found a workaround, it's a bit hackish and I might get stuck somewhere in the future but this is what I'm doing for now:
if Input.is_action_just_pressed("Attack"):
animationPlayer.play("Attack")
func _on_Sprite_frame_changed():
if $Sprite.frame == 35:
shootBullet()
func shootBullet():
var bullet= Bullet.instance()
bullet.set_bullet_direction(sign($Bullet2D.position.x))
get_parent().add_child(bullet)
bullet.position = $Position2D.global_position
So basically, I call the animation to play and then look for a change in the animation. When the frame reaches the frame I want, it shoots the bullet.
I love to find a better way if there is one.