Sign in to follow this  
vittis

Simple physics question about Mini Golf game.

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

Share this post


Link to post
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.

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.