Adjust AnimatedSprite.frame value assignment behavior to improve integration with AnimationPlayer #13116
exhaust-pipe
started this conversation in
2D
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
AnimatedSprite2D/3D
is so great — it allows multiple textures in a single node, and makes it easy to set up animations and frame sequences.However, its built-in animation playback is relatively simple, so I tried using
AnimationPlayer
instead to control its animations.This seemed like a perfect complementary solution, but in practice I encountered the following issue.
Let’s say I create a simple linear sprite animation that plays from frame 0 to frame 10 over 1 second. The most intuitive way to do this in an AnimationPlayer continuous track is to set two keyframes:
Keyframe 1: at 0.0s, frame = 0
Keyframe 2: at 1.0s, frame = 10
Intuitively, the frame value should linearly progress from 0 to 10 over the course of one second.
However,
AnimationPlayer
seems using floating-point interpolation between integer keyframes, and when that float value is applied to the integer propertyAnimatedSprite.frame
, the engine rounds the value by default.This leads to unexpected timing issues:
Because of rounding, the first frame is displayed for only half of its intended duration, and all subsequent frames appear half a frame too early.
This breaks the linear playback rhythm, which is especially noticeable for short animations or those that need precise synchronization.
Existing workarounds
Requires manually keyframing every frame.
Loses the benefit of AnimatedSprite’s pre-defined frame order.
Prevents AnimationPlayer from recognizing it as a frame property, so you can’t preview animations directly.
Can set invalid frame values without triggering an error.
Loses the simplicity and ease-of-adjustment of continuous tracks.
Potentially doubles resource usage due to higher FPS.
All of these workarounds reduce the synergy between
AnimatedSprite
andAnimationPlayer
.If Godot could change how
AnimatedSprite.frame
handles float assignments — specifically, by truncating instead of rounding — this issue could be solved.One possible approach (sorry I’m not familiar with Godot’s source code, so this is just an idea) is to add a new exported enum property to
AnimatedSprite
:This would allow
AnimatedSprite
andAnimationPlayer
to work together much more effectively for animations.Beta Was this translation helpful? Give feedback.
All reactions