• General Chat
  • Can AnimationPlayer have units of frames instead of seconds?

I'd like to have an animation be exactly 4 frames in duration. But AnimationPlayer has units of seconds. At 60 FPS, 4 frames converts to 0.067 seconds. AnimationPlayer rounds this to 0.07 seconds. This is between frame 4 and frame 5. How does AnimationPlayer handle this? Does it cut the animation off at frame 4? Or does it extend the animation to frame 5?

Would this be better suited for AnimatedSprite?

I think it depends. I do not really do a lot of 2D work in Godot, so I'm not positive, but I think what I wrote below is what will happen with an AnimationPlayer.


If each frame is positioned at 0.07 seconds, and the length of the animation is 0.24 (0.067 * 4) then your frames will be at the following positions if you try to fit them into a length of time 0.24:

-| Frame 1 : 0.07 -| Frame 2 : 0.14 -| Frame 3 : 0.21 -| Frame 4 : 0.24

Notice how frame 4 has to be cut short to fit the 0.24 time range. If you put Frame 4 at position 0.28 in a AnimationPlayer of length 0.24, then it will never reach Frame 4 and so will skip it.

If you make the length of your animation player instead to 0.28, and position all four frames 0.07 length apart, then it should play the animation at almost the correct speed (just a tiny, tiny bit slower than 60 FPS).


I have not used AnimatedSprite, so I have no idea if it is better suited or not.

I know that you can get around this issue if you use GDScript and a Sprite node with a sprite sheet. You just need to use delta to figure out how much time has passed between each frame. Once 0.067 or more time has passed, you just increase the sprite's frame by one, and loop the sprite's frame back to zero if the frame number is more than the last frame of animation in the Sprite.

Hopefully this helps! :smile:

Hmm interesting. Thanks for the response. I will do some testing and post back here if I figure anything out. In the meantime I'll wait to see if anyone else has any info to add. Thanks again.