2
votes

I am making a 1v1 multiplayer game such as 8 ball pool using unity. The overview of the approach I am using currently is: 1) Sync positions of each ball on both players. 2) If it's player1's turn: Get vector3 force applied on white ball and run the physics on 3) Send force from player1 on white ball and run it on player2. 4) Change turn once all balls are static or pocketed.

Problem is that even though: White ball's initial position and force applied are same for both players. The end positions of all balls are not the same. There is randomness in the physics I guess. The balls move and behave differently especially after collisions. There is sort of a butterfly effect and the end result of positions of balls on table is different for both players.

My question is that how will you approach in making a 1v1 8 ball pool where there are lot of objects and physics going around and ensure that everything happens the same way for both players.

1
can you please share your code of ball movment? - Muhammad Faizan Khan

1 Answers

2
votes

Physics need to happen on a single instance of your app then propagated to others from there. Otherwise said, one player should be server + client and other players should be clients. All physics happen on server and clients send their commands to it like force applied on white ball, direction, etc.

Unity HLAPI for networking : https://docs.unity3d.com/Manual/UNetUsingHLAPI.html