Kreeba Posted July 12, 2017 Share Posted July 12, 2017 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. webdva 1 Quote Link to comment Share on other sites More sharing options...
ForgeableSum Posted July 16, 2017 Share Posted July 16, 2017 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. Quote Link to comment Share on other sites More sharing options...
Raggar Posted July 16, 2017 Share Posted July 16, 2017 You could also try the Spaaace example of Lance GG: https://github.com/lance-gg https://github.com/lance-gg/spaaace It should be close to what you want. Quote Link to comment Share on other sites More sharing options...
Kreeba Posted July 30, 2017 Author Share Posted July 30, 2017 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. webdva 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.