Saving entity states for networked physics
Posted: Thu Feb 28, 2013 2:08 pm
Hi all,
I am currently working on a networked FPS and have run into some problems while implementing client side prediction.
Essentially, my clients send input to the server, and at the same time execute the input themselves. The server receives the input, performs the same move code and then sends back the result. When clients receive the result they must reset their player position to the server position and replay all input commands from that point until the current time. This allows clients to move with no input lag by staying slightly ahead of the server.
The problem I am getting is when I reset a player to a previous state. If my server sends a position to my client, I teleport my character controller to that position and even If I call an update with no move commands, after a teleport the client seems to move anyway. I can see on my server that the entity is constantly at the same position, but when I send that position and teleport to it on my client, the update loop seems to move it slightly so I am getting a jittering effect.
Is there a way to teleport a character controller (or any entity for that matter) so that it is in the exact same state that it was in on the server. IE the server doesn't move using the same position data which I send to my client, so my client shouldn't move either.
I am not sure if it is the TeleportToPosition() function I am using or whether I need to send a lot more data about the state of the entity. I can use a history of saved states on my client to rewind to if it makes it easier.
Any tips would be appreciated,
Thanks
I am currently working on a networked FPS and have run into some problems while implementing client side prediction.
Essentially, my clients send input to the server, and at the same time execute the input themselves. The server receives the input, performs the same move code and then sends back the result. When clients receive the result they must reset their player position to the server position and replay all input commands from that point until the current time. This allows clients to move with no input lag by staying slightly ahead of the server.
The problem I am getting is when I reset a player to a previous state. If my server sends a position to my client, I teleport my character controller to that position and even If I call an update with no move commands, after a teleport the client seems to move anyway. I can see on my server that the entity is constantly at the same position, but when I send that position and teleport to it on my client, the update loop seems to move it slightly so I am getting a jittering effect.
Is there a way to teleport a character controller (or any entity for that matter) so that it is in the exact same state that it was in on the server. IE the server doesn't move using the same position data which I send to my client, so my client shouldn't move either.
I am not sure if it is the TeleportToPosition() function I am using or whether I need to send a lot more data about the state of the entity. I can use a history of saved states on my client to rewind to if it makes it easier.
Any tips would be appreciated,
Thanks