Jump to content

  • Log In with Google      Sign In   
  • Create Account


Players colliding and pushing against each other


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
1 reply to this topic

#1 BlinksTale   Members   -  Reputation: 315

Like
0Likes
Like

Posted 22 February 2014 - 06:11 PM

New guy to the networking board here (although I have been blessed by the knowledge of the graphics boards before). I'm making my first networked game, and it's a 3d platformer. I'll be allowing players to jump on each others' heads, shove each other around, and in general physically interact a good deal - but they're just cubes, so it's rotation, position, and momentum. That's it.

 

So right now, I'm having my local game send my local character data of position/rotation/momentum to the remote game, where a copy character represents my local character in that remote game. So, it's a 1:1 of me in the offsite game.

 

Now I've got my local character, and the offsite player decides to take his offsite character and push it into the copy character. In local play, one character pushing against another leads to the pusher pushing the pushee around. In networked play though, the copy character is told to maintain that exact position based on the data my local game keeps sending about my local character. This leads to either no pushing or very slow pushing, because everything has to first go across the network twice before any real movement is made. That's bad!

 

So how can I fix this? If I don't send position, the momentum could ruin where they end up if any packets are lost. If I send position back and update my local character with data from the copy character, won't that overwrite my new controls/momentum/input that I'm sending locally? And if I just average everything, it moves at half speed.

 

The closest idea I have so far is that I should send the data both ways, but I have to be careful with my timing. Eg. I would read in the data sent back at the beginning of my game loop, so the first thing that happens is updates from across the network are applied, then I add my own changes with input, and then I finally send out that new broadcast of data at the end of the gameplay loop. But would that really work, or just lead to more cases of the players locking up against each other?

 

Thanks!



Sponsor:

#2 hplus0603   Moderators   -  Reputation: 5164

Like
3Likes
Like

Posted 22 February 2014 - 11:57 PM

Player/Player interaction is the hardest problem to solve in networked games, because of the inherent latency.
You're going to have the latency somewhere; your game design choices are all about deciding where it will be hidden the best.
For example, you can use inertia when moving cubes; this inertia means that all movement messages have time to get to the server and back before you actually see them, and the server can have a full, authoritative view.

Thus, I suggest you run the physics simulation "for real" on the server, and use the data from the server in what you display to users. Just send the input from the clients to the server. This will make for some command lag, but will make sure you get no inconsistencies in the game.
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