Jump to content

Simple physics question about Mini Golf game.


vittis
 Share

Recommended Posts

Hey guys,

So, I'm an experienced game dev, but I focus mainly on making turn based games.

Right now I'm doing a multiplayer Mini Golf game with nodejs.

I assume the physics calculations must be done on both server side and client side and some adjustment must be made to sync them.

The question here is how to achieve the collision behaviour I expect? I know it's a very simple system(mini golf) but I don't know much about programming physics, should I use an existing library to handle the collisions? Should I write my own? I don't know really where to start. Any guidance would be welcomed. I'm attaching a sample course layout so you know what it is about.

Thanks!

minigolf.png

Link to comment
Share on other sites

Since your posting in the Phaser3 area, I assume you are already using Phaser3, which comes with a Physics library already.

You will have to add your course and your ball to the physics engine. Then you can simply set the x/y velocity of the ball and the collision/bouncing will be handelt by the physics engine.

The Phaser3 lab examples may guide you. Most of the examples activate gravity, but you can just leave it out. Make sure to activate bouncing though, otherwise your ball will probably just halt at walls. (Physics examples: https://labs.phaser.io/index.html?dir=physics/arcade/&q=)

Looking at the network part: Depending on your players you could simply "trust" the clients and let them do the physics calculation only (broadcasting the velocity to all clients) but that opens doors for cheating.

To avoid cheating you can also run the physics on the server and syncing states with all clients. It may be enough to sync the ball position bevor the next shot, but that may lead to some ball repositioning. Alternative you could try to reposition the ball every other frame (or fewer/more often). Not sure how well it works but it would be worth a try.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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