I have a mesh with collider that needs to exist on both server and client. It is moving on a predefined path and timing. This is why I am thinking it should be possible to sync without wasting a ghost on it. The player can stand on top of it and move with it. Currently the player is jitters since the server and client are not perfectly synced. Client starts right away while server starts when it receives the RPC. First question - what can I use to sync the starting of the movement - I don’t think sending DateTime.Now() or SystemAPI.Time.ElapsedTime would be accurate as they are not guaranteed to be the same on client and server machine? Second - even If I manage to sync them perfectly, would that solve the jittering for all players? I am sure I am missing some fundamentals of networking here, so any learning resource reference would be appreciated!
You should make the platform a ghost. The networking model will handle all of this for you and stop the stutter. What you are probably seeing is the platform being in the wrong position (as it doesn’t form part of the snapshot) when the client is running its network update.
Thank you for the response, I was hoping there is a different solution since you have a limited number of ghosts from what I understand.
SystemAPI.Time.ElapsedTime are not synced, but SystemAPI.GetSingleton().ServerTick are. Client side this will be the predicted value and server side it’s the current tick. You could modulo this to find where on your path the platform is.
How exactly do I transform this to time, server ticks are integers. I have attempted syncing the animation time and server tick from the server to the client through ghost fields. On the client I would subtract ghost server tick from predicted server tick and get an integer.
I have attempted to multiply that integer by 1/60 which is the network tick rate (all tick rates I could check were 1/60, I do not remember the details precisely now) to get the time delta between server and client. Then I add this time to the ghost animation time. This led to jittery results so the prediction was not good (seemed to be predicting animation further along than necessary).
The system I was on did not run 60 frame a second more like 40 not sure if that affects fixed delta times (the animation was processed in fixed time on server and client).
Two questions - how do I transform server tick to time and are there any examples I can see on how prediction of a transform (or anything) actually works in netcode for entities?
What I ended up with was a predicted ghost platform that only syncs the time it uses to animate itself in a ghost variable. Apparently ghost variables like that are automatically predicted on the client. It is not quite what I was talking about but I am still learning.
You can use a NetworkTime.ServerTick to get a deterministic position on both client and server, instead of relying on ElapsedTime (that is at the moment not synced, the elapsed time on client and server processes can be different).
The function is up to you to implement, but using NetworkTime.Tick.TickIndexForValidTick you can implement a method that always return the same position on both client and server for a given server tick.