Search Unity

Improve lag with Game Center Mulitplayer iOS with Unity

Discussion in 'Scripting' started by ravinder, Aug 2, 2015.

  1. ravinder

    ravinder

    Joined:
    Aug 25, 2010
    Posts:
    150
    Hi,

    I have been working on a game. It's kind of big and I am working on the realtime multiplayer part using Game Center with U3DXT Plugin for Unity3D. The game lies in the fighting genre where at maximum two users can play at a time and both are having their own team of 5 players each. Now the problem arises in syncing their positions on two devices. If any one of them loses it's position even by a small margin then the game takes a completely different shape as they start fighting with each other.

    Consider a scenario where one player of Team A is at point A on device1 whereas the same player is being reflected at point B on the other device. So what happens is on 1 device it starts fighting with the other team members whereas on the other device it stands idle. I don't want to send too many states across the servers as it slows down the game.

    For their movement, they move on behalf of touch on the ground. The player moves to the position where you have touched. I used reliable method to send the position and to cover up for the latency. I am using this maths:

    For the message passing I pass on the current time from the device 1 to be sent over along with the touch position

    On the receiving end I get the current time and compare it with the time I got from the device 1

    float delay = Time.time - timeFromDevice1
    float latency = delay/1000 (for milliseconds)

    speed = speed + latency; [this is the speed with which a player moves on the receiving end]


    The problem become much more noticeable when you move all the players at the same time.

    Please if anyone having experience on multiplayer with game center can help me out to get out of this situation will be much appreciated. Even any inputs to improve it can be of much help.

    I will be waiting earnestly for replies
    Thank you in advance.

    Ravinder
     
    Last edited: Aug 3, 2015