Jump to content
  • Advertisement
Sign in to follow this  

Collisions between players in multiplayer racing game

This topic is 865 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'm creating a simple racing game (spaceships, no gravity) using p2.js, phaser and node.js.

What I have done:


Client receives world state from server:

  • extrapolate other players based on latest velocity/position from server
  • check if client-side prediction was correct - if no apply position from server and process inputs that server was not aware of.
  • fixed physics step


  • receives inputs from clients and apply
  • fixed physics step
  • sends world state to each client

Now I'm struggling with collisions between players. Colliding player is jumping all time during collision. I think it's because client-side prediction is not calculating similar results to the server.

Server doesn't know all inputs from player (lag).

Player doesn't have the same position of colliding player as the server (lag).

Combining this two makes the client to resolve collision different than the server and when world state arrives player has to make a big correction.


Share this post

Link to post
Share on other sites
That's correct. Handling player/player collisions is one of the hardest things to do in networked game design.
The higher the latency, the more you have to be able to "hide" the bad effects of client mis-predictions.
If you're using a web browser and websockets over TCP, you're almost guaranteed to have a higher latency than a native, UDP-based game would, too, making the problem more noticeable.

Share this post

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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!