Jump to content

Server-side Physics Advice


Kreeba
 Share

Recommended Posts

I am tinkering around with a simple Multiplayer battleship 'Asteroids' game using nodejs on the back-end. I think I will use Babylon3D on the front end, but everything will be limited to a 2D plane.

I am looking for the best way to simulate the players ships on the server. Ideally I would like the player to be able to specify the heading (as an degree angle in world space) and speed and it will calculate it for me and send the x/y/rotation back to the player to sync their view. Later I would like to use the same engine to simulate on the client, using an authoritative server model, to make the visuals smoother.

The engine or calculations would need to handle slow turning of the ships, with momentum, and also simple circle/circle and square/square collisions.

What am I looking at here? Should I go down the route of a simple 2D JS physics library? If so, how would I enter the desired direction angle and get the player ship to turn to match the desired angle?

I am experienced at web application coding but maths/physics is beyond me.

Thanks for any advice.

Link to comment
Share on other sites

Don't calculate physics on the server side, that is a recipe for disaster. Calculate physics on the client side - server should only be used for relaying and validating data between clients. 

It will be extremely difficult to hide lag if your clients are reliant upon the server for everything that happens in the game. 

Link to comment
Share on other sites

  • 2 weeks later...

To complete this thread, and mark it off as solved. I ended up coding my own small physics functions (physics as in basic movement, not a full on 'physics engine') that served my purpose.

Some online games do implement a full physics engine server-side, but it was a little overkill for my needs.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...