A few questions regarding physics and game security

If you decide to try and help, be sure to read everything below carefully.

I might as well include all of my questions in this one single thread. Let me begin!

So, my mini golf game is entirely physics based. Each ball is created on the server and assigned network ownership to their corresponding client. Ball movement is handled by a LocalScript.

Effects such as sounds when landing in the hole, or floaties activating when landing in water, are handled locally. The floaties are replicated using a client side Touched event for all balls, even if it isn’t yours.

Before I start moving on to anything else, I really wanted help with a few very important key parts of the game in order to maximize potential.

My two biggest problems are collisions and game security.

First of all, since everything is done on the client, game security doesn’t exist. Everything can be manipulated, and according to my friend, its near impossible to set up game security on a physics based game.

Secondly, since all of the balls are set to each client, collisions between balls aren’t good. I really want there to be proper collision, even if I have to learn to write physics replication or something like it.

This game really means a lot to me, and I would be willing to work hard to solve these issues. If you have any possible solutions, do not hesitate to talk to me below.

Thanks.

If you would like a take a look at the game:

1 Like

You could scrap the network ownership idea and have the client detect input for direction and hit velocity and send to server.

Server could then verify those values are possible and fire back to all clients telling them to hit the ball at those values, delaying a static ball position change until the end of the turn.

The only issue you would have is determining the end position without actually running the hit on the server, but you could just do that too.

1 Like

Wouldn’t this cause latency?

1 Like

Not if you do some lag mitigation, such as
… playing a swinging animation before the hit which lasts longer than the expected ping, or
… creating a local ball that no-one else sees and making it move right away, as soon as the request is sent to the server.

The former will keep the lag and even make it last longer in most cases, but it’s expected and consistent.
The latter would need some synchronization with the server after it’s confirmed and simulated on the server, such as lerping the visible ball’s position between the client controlled ball’s position and the real, server controlled one.

1 Like

Have you thought about doing sanity checks?

1 Like

You can put some sort of max speed ingame based on the highest height drop and starting speed.
If someone moves faster than it just put them back to their starting position.

1 Like

The main problem is collision with other balls. If every client and the server all have their own clones of every ball, which all then have to lerp back to where the server decides they were meant to end up, that could look really weird really quick.

In theory physics should be consistent. In actuality it can vary a bit.

In terms of making physics as consistent as possible, I’d agree with having multiple balls for the client and server and then having the server make the final decision on where the balls end up.

In terms of security I can’t urge the use of Sanity checks on the server enough. Make sure that you leave a little room for inconsistencies, since it is all physics based. An example could simply be resetting the ball if it travels too quickly. Even if they aren’t exploiting, it could help with situations where physics glitching occurs.

3 Likes

You may also want to try and detect if the ball has been moved or teleported to a new position, and if so, return the ball to its former position. This is in the event the player tries to exploit the ball to a hole.

Another check would be to see if the player’s stroke count is greater than 0 for when they make it into a hole. Obviously, there’s no such thing as a hole-in-zero.

I’ve recently began to tamper with physics similar to mini-golf. I have ball-collisions disabled and the networkowner set to nil, and it seems to be alright for the moment. I haven’t really toyed with multiplayer yet. Good luck, and your project is looking great!

2 Likes