Advertisement

I need help designing the physics engine

Started by November 22, 2017 01:04 PM
1 comment, last by hplus0603 6 years, 11 months ago

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?

 

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.

enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement