Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Applying Server Corrections to Client Physics


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 wilberolive   Members   -  Reputation: 286

Like
0Likes
Like

Posted 10 June 2014 - 10:31 PM

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?



Sponsor:

#2 hplus0603   Moderators   -  Reputation: 5723

Like
0Likes
Like

Posted 11 June 2014 - 06:19 PM

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?
enum Bool { True, False, FileNotFound };

#3 wilberolive   Members   -  Reputation: 286

Like
0Likes
Like

Posted 11 June 2014 - 07:01 PM

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?



#4 hplus0603   Moderators   -  Reputation: 5723

Like
0Likes
Like

Posted 12 June 2014 - 09:53 AM

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.


enum Bool { True, False, FileNotFound };




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS