I have finally decided to revisit this game with the intention of making it multiplayer. I will be using the fairly new Photon Fusion multiplayer add-on for Unity as it is the most recent and supports a dedicated server host which is what I’m looking for.

I’m re-writing the code from scratch since multiplayer is a whole different ball game (pun intended) from an offline game. However, I will certainly be learning a lot from my previous offline version and will reuse most of the graphics and 3D models.

The first major hurdle in creating a game like this is to try to hide the lag as much as possible. Lag is obviously unavoidable in a server-based game as it takes time for what’s on the server to reach each player. So, the trick is to make it feel like a local game when it really isn’t.

The game is server authoritative, so the server always contains the correct situation in the game, so the true ball position is on the server. If you just show the server ball position to the player it will feel very laggy and unresponsive. So, to get around this I created a local ball which the player uses and sees which mimics the actual server version. This removes any sense of lag when controlling the ball. The actual collisions with the ball still happen on the server and are reported to the clients.

Here’s a quick look at how my initial code looks. I’m running two clients side by side. They are both connected to the dedicated server which isn’t shown. As you can see the local controls (player on the right) are very responsive. Player two is just observing him. If you are very perceptive you will see that player two’s view is ever so slightly behind player one as he is seeing the game as reported by the server.

Categories: Futsal Game


Leave a Reply

Your email address will not be published. Required fields are marked *