Skip to main content
GameDev.net gamedev.net
🔒 Locked

Decoupling ticks from frames to avoid unconsistent input send times - Unity

Started by baludevy Apr 7, 2025 at 9:19 PM 1 replies 2.3k views
Original Post
baludevy
baludevy

Hey there, I'm doing netcode for my own fast paced fps and I've ran into some roadblocks.

The roadblocks I ran into is sending inputs to the server. Right now, I think I have the design that's most suited for fast paced games: The server expects a healthy input stream from clients, where healthy means that there is always an input to process when the server is processing it's own tick. The problem is that the client might miss a tick because its tick intervals depend on framerate, at 64hz the client only has perfect 15.625ms tick intervals if it's framerate is perfectly a multiple of 64. The only way I found on how to account for this inconsistency is buffering inputs. But for a fast paced game, buffering is bad. The goal should be to execute the inputs as soon they arrive. Based on my findings CS2 does exactly that.

I'm wondering if there is anyway to guarantee that there is 15.625ms between each tick, as long as the framerate is above the tickrate, but not a perfect multiple of the tickrate.

frob
frob

Not really a good way to do the perfect time per network tick, as you can't easily predict network jitter. Also clients are likely to have time windows with no updates, and time windows with lots of updates. There may be someone running around may have seconds with no corrections, just running forward with no events or turning or course correction, similarly someone waiting with a sniper may have a long time just waiting and watching, both may be followed by a fraction of a second with a flurry of events.

In general it's better to send events over the network as they happen, not a continuous stream of updates based on the clock. There was an era 30 years ago in the Golden Age of RTS where RTS games used lockstep networking and coordinated network ticks, but they were often 4 or 5 or 6 ticks per second. For a modern shooter, send events as soon as they're available to bundle up and transmit, it doesn't need to be synced to video framerates. It's generally more important to transmit timely notifications rather than a regular tick from the clients, although there should still be enough traffic with a heartbeat event if nothing was sent recently.

Similarly on the host, process all events when they arrive. If you're doing a type of simulation that rewinds time and re-simulates, you'll need to account for that as well as any sliding time windows for when you want to inform clients of what the authoritative state of the world should be.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.