Syncing FPS with animation

Greetings, I am working on a guitar hero style rhythm game using UPBGE. If I create an animation that lines up with a songs BPM at 60fps, how do I make it so that if the FPS dips below 60fps, it will not get out of sync. Thanks!

I don’t know if syncing with framerate is the way to go, because you’d be relying on an estimate.
Try printing out bge.logic.getAverageFrameRate() to console, every time you get a new float.

Guessing it should be possible to take this and assign to bpy.data.scenes["scene_name"].render.fps, which sets the effective animation framerate.
But this won’t work on standalone player, so likely not what you want. Plus, having the animation slow down won’t slow down the song, so it would still be out of sync.

I’d think about forcing the frame on the action to correspond to the current time on the song.
Something along the lines of action.frame = (elapsed seconds*animation framerate). I’m not entirely sure though; perhaps someone else has a better idea?

1 Like