Mirror icon indicating copy to clipboard operation
Mirror copied to clipboard

Feature/network tick v1

Open NiftyliuS opened this issue 2 years ago • 4 comments

Syncer to sync network ticks between client and server and convert RTT to ticks. This allows for easy client side prediction and more consistent client inputs to be played on the server.

High level of how this works: ( i added tons of comments in the code ) There are 4 modes for the syncer each has its own handling. 1 - Initiating - This will send 12 ticks in rapid succession to allow a solid initial time and ping sync with server 2 - idle - fires 2 times a second and uses info to verify that the ping did not change and that client and server are both in sync ( if server or client get stuck the server tick will be out of sync and adjusted here ) 3 - Accelerated - Is activated when something changes - fires 5 pings a second ( total of 12 ticks ) and then verifies 4 - Verify - When idle detects a desync it will enter Verify mode - it will fire pings to verify that there is an actual change and not some network throttling

The ticks resist any change unless it is consistent (over several pings). And RTT tick calculation will ignore changes +-1.

The whole thing works in 2 modes: Rapid adjustment - when sync values differ greatly and ping has a significant change ( ~2-3s to adjust ) Lazy mode - will count over time if there is a consistent difference of +-1 and adjust ( ~ 15-30s to adjust )

The syncer also has Virtual functions to adjust physics when ticks are adjusted.

There are 2 average functions - each of them takes 12 ticks and ignores the min and max values (that removes the majority of spikes from calculations )

NiftyliuS avatar Apr 04 '22 20:04 NiftyliuS

I have a testable version in https://github.com/gamerguardio/mirror-fps-prediction ( also readme ). I am not sure if there is a way to add it to the PR somehow ( the readme )

NiftyliuS avatar Apr 04 '22 20:04 NiftyliuS

thanks for pull request. we will take a look asap. few more other issues first :)

miwarnec avatar Apr 05 '22 04:04 miwarnec

hey @gamerguardio , could you share the resources this is based on?

was this used in any known project or is this improvised?

miwarnec avatar Apr 30 '22 14:04 miwarnec

code is very clean and easy to read btw. thanks for PR

miwarnec avatar Apr 30 '22 15:04 miwarnec