#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)

limber rover
#

yes i tried chat gpt i got mad

#

ok

#

my problem is it always just stays on the last frame of the hit animation

#

and never goes back to idle

meager forum
#

Does it print your animation finished debug message?

limber rover
#

lemme check one sec i dont think it does

#

it doesnt

#

it might be somwthing really dumb im new lol

meager forum
#

Never used AnimatedSprite2D, but could it be something with the animation itself that is configured wrong?

limber rover
#

yea

#

i can try making a new project

#

so nothing will be changed

#

then redo my stuff

#

how would u do it

meager forum
#

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")
limber rover
#

that looks super simple

#

ur smart

#

ill try

#

also whats a coroutine😭 im dumb

meager forum
#

🙂 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.

limber rover
#

yea

meager forum
#

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.

limber rover
#

ok

#

i understand

meager forum
#

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"

limber rover
#

ok

#

so thats what that await is

#

i think im kinda understanding this

#

ill try it then noptify later