|
|
|
|
|
by diericx
4013 days ago
|
|
I actually just noticed a bug in my code where I was only looking for data from the server every 20 milliseconds rather than every frame. Now the movement is smooth but the controls feel a bit sticky. I made the client send every 10 milliseconds and it looks pretty good, but this is a really bad way to solve this problem. I'll look at your links and try to optimize it better! Thanks a ton for those:) Edit: I read your keynote and I'm not sure how exactly your client prediction worked. Is there any video anywhere of the keynote? Or could you give a brief description? |
|
So for example if a player is going left, every time the game steps forward one frame move the player left.
Then when a message comes from the server with the current game state, update everything to the server positions and then step your game world forward to now.
So a simplified example - we have one object in our game that has an x position and a delta x to move it.
So we set our local state to what the server says and then step forward by 4 frames to get what we think the current state should be. We ignore this message from the server as it's out of order (we've already received frame 7) No need to do any stepping forward from this server state as we are in sync.One thing to be careful of is that normally it's not just a case of saying it's 4 frames so I just multiply everything by 4 to get the new positions. With physics engines and more complete calculations you probably want to step the world forward frame by frame to get a better simulation of where everything is.
Hope that all makes sense.