#How to exit the attack animation and return to idle and run

11 messages · Page 1 of 1 (latest)

slate heron
#

Hello everyone, I'm new to godot. Me and my friends of university are trying to create our first game. However, I'm having trouble getting the character to return to the idle or run animation. I'll put all the current code and the current animation tree layout below. thanks for any help !!!

#

I even tried adding a timer to stop the attack animation and return to normal. But it didn't work. Note godot I'm using is 3.5.3

slate heron
woeful leaf
#

Have you tried creating a function to invoke your animation player corresponding to each animation sequence?

func do_run(): 
  animation_mode.travel("Run")

func do_walk():
  animation_mode.travel("Walk")

func do_idle(): 
  animation_mode.travel("Idle")

Then at the end of the Player/Functions call method track call your function.

#

It might also be worth taking a look at the AnimatedSprite object.
https://docs.godotengine.org/en/3.5/classes/class_animatedsprite.html

Those have a signal, called "animation_finished()", that is called at the end of an animation cycle.

slate heron
#

ohh thanks a lot man !!! I'll do everything you said !!

woeful leaf
#

You might want to take a look at this section of your code too:

animation_mode.travel("Run")
else:
animation_mode.travel("Walk")
else:
animation_mode.travel("Idle")```

The if/else/else needs to read if/elif/else.
https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_basics.html

if bool_thing1:
...
elif bool_thing2:
...
else:
...