• 2D
  • Animation: Rotation does not reset between actions

I have no idea what I'm doing wrong.. inside "AnimationPlayer" I have 3 animations from the same sprite. all animations work perfectly, in editor and in-game, but as soon as I apply Rotation to the jump animation, the rotation does not reset when the engine switches to a different animation, even in the editor if I switch to "idle" when I'm rotated in the jump animation, the rotation stays.

I thought I found a fix by adding keyframes to all other states telling the player to stand at 90 degrees. but that just overrides the jump animations rotation keyframes making it stationary..

how do I make the keyframes between animations independent of eachother? I feel like that should be the case by default and I'm just doing something weird.. actually while typing this I now can't get my character to rotate at all.. even though it rotates in the animation preview

I have AnimationPlayer and AnimationTree both as children to the KinematicBody2D

as of now I can't even animate jump to rotate. if I animate idle to rotate within the same node then ofc it works. but not jump. the animation plays but it doesn't rotate..

am I somehow just animating the main sprite position and not the individual categories of animations? in the editor it shows the jump rotating. if I switch to idle that doesnt rotate... doesnt work when I test ..I then animate idle to rotate, works somehow..

Maybe it is the animation tree that is causing the issue? I've never used the AnimationTree node in any of games, instead manually blending and changing animations through code.

Do the individual animations work if you disable the animation tree and use something like $AnimationPlayer.play("AnimationName")?

@TwistedTwigleg said: Maybe it is the animation tree that is causing the issue? I've never used the AnimationTree node in any of games, instead manually blending and changing animations through code.

Do the individual animations work if you disable the animation tree and use something like $AnimationPlayer.play("AnimationName")?

yes it seems to be working that way.. but now it only shows the first frame of the jump animation because the code wont let it finish playing.. I don't know how to fix that either x) haha

oh no... I just realized even if I did get to to work the "sprite.flip_h" only flips the sprite.. not the rotation.. so my character would rotate the wrong way if he jumped to the left instead of right.. I guess I cant do this without maybe doing the rotation completely in code.

One thing you could try is scaling the node on the X axis by negative one to flip it horizontally. It could have other issues though, as some 2D Godot nodes do not do well with negative scales.

Edit: Also, to get past the first frame of animation when triggering it manually, you probably need to check if the animation currently playing is not the animation you are changing to. Something like this:

if Input.is_action_just_pressed("jump_action"):
	if $AnimationPlayer.current_animation != "jump":
		$AnimationPlayer.play("jump")
7 days later

@TwistedTwigleg said: One thing you could try is scaling the node on the X axis by negative one to flip it horizontally. It could have other issues though, as some 2D Godot nodes do not do well with negative scales.

Edit: Also, to get past the first frame of animation when triggering it manually, you probably need to check if the animation currently playing is not the animation you are changing to. Something like this:

if Input.is_action_just_pressed("jump_action"):
	if $AnimationPlayer.current_animation != "jump":
		$AnimationPlayer.play("jump")

cool, I finally got it to work, thank you for the help :)