Set AnimatedSprite2D frame in animation with custom frame duration

Godot Version



Being able to set frame duration in an AnimatedSprite2D is really useful, but I cannot find a good way to set the “frame” I want in an animation with arbitrary frame durations.
For example, let’s say I have 3 frames in an animation with 1FPS, with the first frame having a duration of x3 and the rest having a default x1 duration. The animation has an overall length that is the same as another one with 5 normal duration frames. However, I can easily choose to go to frame 3 of the animation with 5 normal frames (aka skip forward 2 seconds) by changing the .frame property, while doing the same to the animation with edited frame duration will put me on the final frame, rather than setting the animation to the first frame and setting the frame progress to 2 seconds.
Is there a way to set the exact point of progress of an animation made of frames with arbitrary frame durations (like how you can set the exact frame of an animation with default frame durations)?

AnimatedSprite2D.frame sets the frame index of the animation. It does not matter if the frame duration is different or not.

You could try with AnimatedSprite2D.set_frame_and_progress() or AnimatedSprite2D.frame_progress but I don’t think what you are asking is possible with AnimatedSprite2D.

If you need better animation control use an AnimationPlayer

I already have several animations with custom frame durations set up in a SpriteFrames object. Is there a way to convert this data to an AnimationPlayer or will I have to do it manually?

You could try using this plugin Animated Sprite to Animation Player Convertor 4.0 - Godot Asset Library

1 Like

Thank you.