Animation won't play, need some help

Godot 4.3

For some reason this particular animation won’t play. I have no idea why this doesn’t work, could someone help?

if Input.is_action_just_pressed("attack2"):
	$Animations.play("Knife")

A few things to check:

  • Is the condition Input.is_action_just_pressed("attack2") okay? Maybe the animation instruction works fine, but is just not called.
  • Is the $Animations node correctly get? I guess so since you’re saying that particular animation doesn’t work, meaning you’re using $Animations elsewhere, but I cannot tell without more code.
  • Is Knife the exact animation name?
  • If everything is working fine in the code you’ve shared, the issue can also come from another animation playing right after “Knife”, for instance in a process function, which would look like the Knife animation doesn’t work, but is actually just overriden.

Let me know if that helps! If not, feel free to share more code/context :slight_smile:

Sorry the code was vauge.

I could try doing the $Animations code again, but not the “Knife” part, I checked to see if that was the right name like 5 times. If I try and press the button while testing it only plays one frame of the animation before going back to idle.

If it plays for a frame and goes back to another animation, either your knife animation lasts for one frame (which would be weird so I guess it’s not that), or another animations plays right after, overriding the knife animation.
Are you playing your idle animation in process?

well I did consider that this line of code is in another script, meaning the idle is still playing while the knife animation tries to play.

but now it only restarts the current animation, never playing knife animation though