Why is this Frame Rate dependent?

I’m attempting to make a network event game loop in blueprint (This is a not-quite deterministic simulation model. Might be a bad idea). I’m syncing up a game clock and then initiating the game loop when the server and clients become synced. I’ve very specifically coded this to .04 seconds per loop for 25fps. Yet when I test it the servers game loop runs rapidly ahead of the client. It’s 100% framerate dependent and I’m not sure why. Any help is appreciated.

NOTE: rollover event function is empty.



Even when there are no events to execute for a minute straight the server flys way ahead of the low FPS client.

bump

Repeating delays is frame-dependent.
You should use a looping timer instead.
See my post here for details

1 Like

That makes sense. Thanks. When using timers - in the event that not all of my commands could be processed in the timeframe (.04 seconds) how would I record that If it just fires off again and never completes?

EDIT: Scratch that - i guess i could have a variable for total commands for that loop and increment a variable for commands executed. then check/react at start of timed function…

Blueprint execution is synchronous - the timer will not trigger again before previous one reached end of execution (either completed or Break the loop).

If a loop takes more than 0.04s, it will hang the game on that frame for as long as it needs, and the next frame will trigger timer again since 0.04s has already passed. Maybe even more than once, eg. if a single frame loop takes 0.10s to complete, the next frame will trigger timer twice in a row. If all your loops take more than 0.04s you will eventually perma-freeze the game, unless you manually Break out of the loops after a threshold like you seem to be doing. But in that case the queue might be ever increasing and events never triggering…

So I could keep this frame timer using the “now” function like I’m currently doing and then break out if it meets or exceeds .04s. Then have a handler if events are getting too backed up - I could just scrap certain events if things get too old. You think that would work? I know there is an underlying game logic & rendering loop happening at the core of the engine. Do you foresee any issues running another game loop overtop of that?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.