How to set animation player/ animated sprite to ACTUAL 60 fps

Godot Version

4.0 - 4.3

Question

So I was recently taking a look at the source code for the animation player for the engine in preparation for a fighting game I intend to continue work on after I’m done with my current project. In fighting games, it is EXTREMELY important to have the framerate of both players to match. Literally more important than ANY other genre. A single frame drop desyncs the whole game.

So, be me. I go to set the animation player to 60 fps only to realize that the player rounds to 0.0167 seconds per frame, which is NOT 60 fps. This has the small side effect of breaking the entire match.

I really want my game to run at 60 fps so I can use moves from other games as reference. Is there any way to make this work with the animation player? I am also willing to use the animated sprite node instead.

There is a “Snap” button in the lower-right corner of the Animation view (when editing an AnimationPlayer). If you disable that (change it from blue to white), will it give you more control over the timing?

My issue isn’t with when the frames in the animation itself are. Well, it kind of is, but less importantly.

The problem is that I need to code to run on every animation frame. I already know that the _process() function is called 60 times per second. What I need is to sync the animation player (or an animated sprite. I’m flexible) so that a new frame is displayed every 60th of a second.

If I disable snap, then I can move around when the images are displayed. That is true. The issue is that it still doesn’t let me sync code with animation well.

If I remember correctly, I think an animated sprite’s frame can be incremented manually within code. However that makes the game run slower. If there is any way to get an animation player to run at true 60 FPS, that would be wonderful

animation_player.cpp/animation_mixer.cpp and animated_sprite_2d.cpp do not use any rounding functions, maybe you are seeing floating point inaccuracy or reading a float from the editor, which does not actually round the number, but shortens how it is displayed by rounding, still using 1/60 in math.

I think the main thing you want is a fixed frame rate? Seems like the best way to get that is by advanced project settings “Max FPS” to 60 and “Frame Delay Msec” to 16, the movie maker mode does something similar to fix the framerate.

Thanks! Just curious. Is it true that the process() function is called FPS times per second? I think for my project I might want to swap out the animation player for an animated sprite that has its frame incremented within code every frame.

Is this a viable alternative to trying to get the project to cooperate with the animation player?

I don’t know if it helps but you can set the callback_mode_process on the animation player to manual and advance the animations manually via code using the advance function (with a custom amount of time).

1 Like

Thanks! I might use this