- Home /
How do I account for lag caused by how UNet syncs SyncVars?
It seems like there is a bit of lag(like .03 seconds) caused by the way SyncVar works.
I'm making a game where the racers are going about 160 mph, and because of this phantom lag the bikes are always a couple of meters behind where they should be.
In my game, the player sends his current Network.Time and his position, and then the server syncs these 2 syncvars up on the client computer. It seems like the lag is caused because,
-The player sends the bike position and the Network.Time that he sent this position at
-Then the server gets this and updates the SyncVar, apparently at the END of the current frame
-Then the client gets the new position and the Network.Time he sent it at
-Then the client must convert the player's network time to his own network time, and then sync the bike position
This works, except I need to push the bikes ahead about .03 * bikeVelocity to make them actually sync up. I think it's because of step 2, when the server gets the position and waits until the end of the frame to update the syncvar.
I'm not sure about this, but I don't know where else the lag could be coming from.