• Advertisement
Sign in to follow this  

Applying Server Corrections to Client Physics

This topic is 1316 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been researching and experimenting with using simple physics in a multiplayer game. Specifically, I'm really only interested in having a character controller move around a 3D environment. To do this, I've been using PhysX, which works great. My game doesn't have any need for more advance physics than that.
 
I have read and followed a lot of the material on Glenn Fiedler's site, which everyone seems to point people to when they start asking these sorts of questions. His material has been really helpful and I've got something working. However, there is one part that I simply cannot get working. That is applying the corrected state on the client when received from the server. Specifically, Glenn says to "rewind" the physics state of the player, apply the correction from the server and then replay the rest of the player's moves.

 

This works fine in a situation where you have explicit control over the player's movements. However, when using a physics engine (like PhysX or Bullet) you have virtually no control over the player character controller's state or the movements it makes. All you can do is apply forces to the player's character controller. It's not possible to rewind the physics state of the character controller to correct it and then reapply the player's unacknowledged moves. How have other games done this using physics engines like these?

 

The best I've been able to come up with so far is to apply corrections using forces. For example, when a correction comes back from the server and I determine that the player's current position is out by a bit from where the server says it should be, I start applying small forces to the character controller to gradually bring it inline with the server over several frames. There's no rewinding going on with this. If the client and server disagree by too much, then I just snap the player to where they should be (rarely happens). Although this "seems" to work, there is a lot of rubber-banding going on when the server says you have run into an object, but the client thinks you haven't for example.

 

Do other games not use entire physics engines for character movement around a 3D level? Do they do something else that gives more control to allow for rewinding and correction?

Share this post


Link to post
Share on other sites
Advertisement

It's not possible to rewind the physics state of the character controller to correct it and then reapply the player's unacknowledged moves.


Why do you say that? How do you handle save/load of level state?

Share this post


Link to post
Share on other sites

Are you implying that I should save the entire physics state of all objects (including the player's character controller) after every simulation step?

 

Then find the matching historical state for the server correction message, reset the physics state of all objects to that historical state, then replay from there, applying the player's unacknowledged moves?

Share this post


Link to post
Share on other sites

That sounds like it could possibly work. You'd probably want to throw away state that's older than some horizon -- say, 1 second -- and disallow inputs that are older than the horizon.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement