Time synchronization, Server/Client

#1
Hey there,

Huge problem. Despite my plans on paper, I'm getting serious out of sync issues on the client.

After some minor bug fixes (ok not that minor, I'm bad ok, pointers to deleted objects XD) I've hit a huge hurdle that no amount of googlin/book-readin/etc. is solving.


Here's the flow:

Client presses button "Spacebar" , saves time.

Server gets button press, does the exact same code as the client and saves time.

Client releases "Spacebar", Jumping (physics impulse up at an angle) based on charge time. (Start time - End time)

Server gets button press, again 100% same code as client and triggers jump.

Positions are sync'd from server -> remote actors. Positions differ from local client!


Sample charge times in seconds:
Client = 0.06705 (released fast) Server = 0.00 (Looks like it was released in the same frame??)
Client = 0.250870 Server = 0.235150
Client = 0.150350 Server = 0.178260

Obviously they differ. I've attempted to do this:
{ "name": "t_FixedStep", "value": "0.016667" }

But that breaks a ton and server-client times differ even more. (e.g. client = ~3 times as much as server)

Some issues I dunno how to fix:
Packets may arrive at different times (relative to each other) compared to how they were triggered on the client.
Differing tickrates. Input could be parsed at slightly different times.

Any help is appreciated. Sorry for bothering but again, no resources I've found assist with this problem (other than identifying it and stating generics e.g. 'just sync inputs')

Re: Time synchronization, Server/Client

#6
It's just obvious that the time will be different for server and client. It will be even waaay more different for clients connected remotely and even more out of sync if they're far away. Let me understand what you're trying to achieve. You want to have jump strength based on how long you hold spacebar right ? So in this case you won't be able to calculate it on the server. Delay for remote clients might be too huge and therefore their jump will be way bigger than they requested. What I would do is.. When you press spacebar, send RMI with current time value and when it gets to the server, save it there. Then when you release spacebar, also send RMI with current time value, and when it gets to the server, server will calculate difference between start and end time, and apply impulse.
Cryengine tutorial videos on my Youtube channel! Check it out !
https://www.youtube.com/user/MusicForLifePL20

Re: Time synchronization, Server/Client

#10
He did not do charge on both. He did charge on server, but what he did test charge time on both to see how much difference there would be.
And this is almost what I suggested. I just suggested sending time from client to server to make it feel more responsive, but yeah. You're perfectly right. The delay will not be bad, it will be usual ping delay.
Cryengine tutorial videos on my Youtube channel! Check it out !
https://www.youtube.com/user/MusicForLifePL20

Who is online

Users browsing this forum: No registered users and 0 guests