Should I always stop an animation before changing to a new one?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By CurioShade

As mentioned above, I am wondering if I should use:

$AnimationPlayer.stop()
$AnimationPlayer.play("new_anim")

every time I make a change in animation, or should I use:

$AnimationPlayer.play("new_anim")

to immediately switch into new one?
I have no idea if either of these two are bad habits, so would like to know some opinion on that.
As an example, is doing something like this correct for Godot?

if movement_dir != 0:
     animationPlayer.play("walk")
else:
     animationPlayer.play("idle")

for this

if movement_dir != 0:
 animationPlayer.play("walk")
else:
 animationPlayer.play("idle")

of course it is right

ramazan | 2022-07-26 16:02

:bust_in_silhouette: Reply From: godot_dev_

In my opinion, it depends on what your design plans for your game is.

  • If you plan to have a complex system around animations start and ends, I’d recommend keeping a distinction between finishing an animation and overriding an animation by playing a new without stopping the previous one.
  • If you plan to have a relatively simple system, I think either approach could work. In particular, if you plan to never to anything in response to an animation ending, you could get away with stopping the animation every time you play a new one.

Below are examples of situations where you probably want to avoid stopping the animation before playing a new one:

  • Having special animations that can only be played after a specific animation finishes (multi-jab attack by spamming the same button, like in Smash Bros., for example)
  • An animation you have might bet punished (super meter, coins, stun, etc.) if it finishes (timesout) without accomplishing anything (e.g., hitting something, landing somewhere, picking up something). So it would be important to distinguish the different between that animation during elapsing (finishing) and being overrided (or canceled) into another animation. In this example, suppose the animation that punishes you for failing to accomplish a goal before the animation ends allows specific animation to cancel it to avoid the punish. Maybe you could jump-cancel (play the jump animation without the original animation finishing) to avoid the punishment . In this case, if you decide to always stop an animation before playing a new one, you will need additional logic to support my above example.

Excellent answer.

DaddyMonster | 2022-07-26 21:10