My 2d character animation is not working properly

Godot Version

Question

I just started using Godot and I have set up my animations for my main character, I have idle, jump, and run animations set up properly… I am trying to set up “Unsheathe” to pull out a weapon, I have the animations frames set up from 0-9, I have “Unsheathe” in the bindings for both mouse and keyboard and controller, when I press those bindings in test play, it looks like it starts or wants to start the animation but it does not. Some of my script is:
if Input.is_action_just_pressed(“jump”) and is_on_floor():
velocity.y = JUMP_VELOCITY

# Get the input direction -1, 0, 1
var direction = Input.get_axis("move left", "move right")

#flip the sprite
if direction > 0:
	animated_sprite.flip_h = false
elif direction < 0:
		animated_sprite.flip_h = true

# play animations
if is_on_floor():
	if direction == 0:
		animated_sprite.play("idle")
	else:
		animated_sprite.play("run")
else:
	animated_sprite.play("jump")  

if Input.is_action_just_pressed("Unsheathe") and is_on_floor():
	animated_sprite.play("Unsheathe")

As soon as unsheath starts, you’re going back to the idle animation.

May be worth seeing about a state machine as ultimately, if the idle animation doesn’t have the sword out, there’s no way to have the sword out and be idle.

If you have separate idle and run animations with the sword out, when add a unsheathed bool and set that then switch over to the animations with the sword out.

1 Like