#How can I make it so whenever I left click it plays my hit animation then goes back to idle.
1 messages · Page 1 of 1 (latest)
ok
my problem is it always just stays on the last frame of the hit animation
and never goes back to idle
Does it print your animation finished debug message?
lemme check one sec i dont think it does
nope
it doesnt
it might be somwthing really dumb im new lol
Never used AnimatedSprite2D, but could it be something with the animation itself that is configured wrong?
yea
i can try making a new project
so nothing will be changed
then redo my stuff
how would u do it
I would try using a coroutine to play an animation once, and then something else. E.g. something like:
func _do_bounce() -> void:
$AnimationPlayer.play("bounce")
await $AnimationPlayer.animation_finished
$AnimationPlayer.play("RESET")
🙂 It might get confused if you have a lot of different one-shot animations, and you might have to add more logic to deal with that, but at least for simple stuff it ought to work.
yea
So normally all the code inside a function is executed in one go, and can't wait for something that takes a long time, since that would prevent anything else from running.
But the coroutine kind of "jumps out" of the current function, allowing the engine to continue doing other things until it triggers, and then it resumes running the commands after "await"