Jump to content
  • Advertisement
Tufan

I need help designing the physics engine

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
Advertisement

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:

https://github.com/bebraw/jswiki/wiki/Physics-libraries

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!