How do i fix animations canceling out each other (I'm a very new by the way)

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

So I have 2 animations one for shooting and one for walking but if I shoot while I’m walking the shooting animation does not play (the sound does play). This is the code triggers the animations.enter image description hereAnd this is the code that has the shooting and walking functions.

I want the walking animation stop and let the shooting animation play then continue the walking animation if the player is still holding down a moving button.

:bust_in_silhouette: Reply From: Wakatta

Image #1

Welcome to the wonderful world of programming.

In your above code every if will be tested and every one to be true will be executed in terms of animation that will be the last one to be shown

What you’re looking for is called an elif conditional statement that must follow an if block
It basically means else if

if a:
elif b:
elif c:

And what happens during execution is if thea condition is false then the b condition is tested and so on until the last elif or else

Image #2

var last_move_pos = 0

func shoot():
    if AnimPlayer.is_playing():
        last_move_pos = AnimPlayer.get_current_animation_position()

func move():
    if AnimPlayer.is_playing():

With more animations and more complex blending it would be better to use an AnimationTree