Sign In Register

How can we help you today?

Start a new topic
Answered

Server controlled multiplayer game

Hi,


We are currently developing a real-time multiplayer game in Unity3d. I have gone through Gamesparks real-time multiplayer tutorial. But we couldn't find solution for our problem.


Our requirement:

1) Client1 sends packet related to attack to server

2) Server approves the client1 packet and will broadcast the packet to all the connected clients (client2, client3)

3) Client1 will be perfoming a "ready to attack" animation till the server approval.

4) When the message is broadcasted and recieved by all clients, the client1 attacks in same time in all the connected clients.


Is there any way to accomplish this through Gamesparks?


Thanks,

Naveen


Best Answer

Hey Naveen,

What you need is a clock-sync in order to simulate the delay between the server and each other player.
This is not simple and there is no way to make sure that the players will attack at exactly the same time on every client, but there essence of it works as follows (see clock-synchronization tutorial for details)...

1 - At regular intervals (say each second) every client sends packet to the server with a time-stamp.
2 - the server caches the latency (time-difference) between the client and server. You now have a rough estimate of how out-of-sync each client is with the server.

3 - player1 send attack packet to the server.

4 - the server sends another packet with that attack data and also its current timestamp plus the highest latency it has for all players
5 - client-side, the time is cached and it is constantly checked against the current time until the time is up and then every player run the 'attacked' code (including player1)

This is not an ideal scenario however, as it moves the game-code into relying on the player with the worst connection which will degrade the experience of all other players.


Sean

1 Comment

Answer

Hey Naveen,

What you need is a clock-sync in order to simulate the delay between the server and each other player.
This is not simple and there is no way to make sure that the players will attack at exactly the same time on every client, but there essence of it works as follows (see clock-synchronization tutorial for details)...

1 - At regular intervals (say each second) every client sends packet to the server with a time-stamp.
2 - the server caches the latency (time-difference) between the client and server. You now have a rough estimate of how out-of-sync each client is with the server.

3 - player1 send attack packet to the server.

4 - the server sends another packet with that attack data and also its current timestamp plus the highest latency it has for all players
5 - client-side, the time is cached and it is constantly checked against the current time until the time is up and then every player run the 'attacked' code (including player1)

This is not an ideal scenario however, as it moves the game-code into relying on the player with the worst connection which will degrade the experience of all other players.


Sean

Login to post a comment