Jump to content
  • Advertisement

I need help designing the physics engine

This topic is 695 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 am new to multiplayer games, i can handle player movements but when the topic is server-side physics i know nothing.

I need to handle physics on the server for my new game, which has like 50 entities in a game room. I never tried to make a physics engine before, i need to make something like this.

I have no idea how to handle collisions like in the video, i will be using node.js as my game server, any ideas/examples how to do it?


Share this post

Link to post
Share on other sites

That looks like very simple circle/circle distance queries and pushing them out of the way. circle/circle collision is simply checking whether distance between center points is smaller than sum of radii, and collision separation axis is simply vector between center points, normalized.

Anyway, there are a number of 2D physics libraries for JavaScript. You can easily find them on Google. Try something like this list:


Then, you have to make the important decision: Do you "speculate" (simulate ahead, and get corrected by the server) on the client, or do you send commands to the server, and only show the server-validated outputs of those commands? And if the former, how do you deal with being told the player didn't actually do what they think they did?

And then the second decision: Do you show "remote entities" sent from the server to you, in forward-extrapolated positions (estimates of where they are "now") or do you show them in known-correct positions, in the past? And if the former, how do you deal with players thinking that they could see/shoot/whatever a remote player, where that position was only estimated and in actuality they were behind cover?

You need to decide what you want for your gameplay, first, and then you can think how physics and networking interact.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!