AnimationPlayer Hiccup

Godot Version

4.4.1

Question

So, I am running into a weird issue and I can’t tell if I am just super dumb or if this is a bug or what. I’m just setting up my player movement, nothing major, and I have all the animations saved in an AnimationPlayer node. When I’m writing the script I have a reference to the node, and I can play animations just fine. The weird thing is when I try to set the idle animations to play.

I am trying to set up a variable to hold whatever the current animation is and set that using get_current_animation, aaaaaand Godot is telling me that doesn’t exist. Double, triple, quadruple checked in the documentation. I’ve tried searching around to see if this is a reoccurring problem. I aint finding squat.

So either I’m missing something insanely obvious, or…? I’m not sure what the or is, honestly. An example of how I’m writing it would be:

var current_animation = animation_player.get_current_animation()

if direction_x > 0:
animation_player.play(“walk_right”)
elif direction_x == 0 and current_animation == “walk_right”:
animation_player.play(“idle_right”)

Apologies if this is a dumb question! Still getting to know the engine, but the help would be appreciated!

That appears to be the getter function of the current_animation property of AnimationPlayer.
Try this:

var current_animation = animation_player.current_animation

Hope this helps!

That did indeed work. I was just missing something very obvious.

Thanks!!!

1 Like