Search Unity

Received state update when Reconnecting to Server

Discussion in 'Multiplayer' started by susdorf, Aug 20, 2009.

  1. susdorf

    susdorf

    Joined:
    May 29, 2009
    Posts:
    60
    Dear community,

    since three days I grapple with Unitys Network State Synchronisation in an Authorative System.

    First let me explain the problem:
    Having a server(0), client(1) and another client(2).
    The order that (1) has connected before (2) is important. Everything works fine, when (1) and (2) are connected to (0), they are able to walk around even when the game has already started by (0). But: When (1) reconnects to (0), the player spawns and only (0) and (2) can see him walking around if (1) is moving, but (1) can only see him staying around. So (1) is not getting the Received state from (0) for (1) transformation NetworkViewID, all the other clients do.

    But when (2) is reconnecting, everything is fine. Always with the last client there are no problems reconnecting.

    Now my system:
    A Player Object contains two State Synchronisation: One for the transformation and the second for the input.
    (0) is allocating a new NetworkViewID for the transformation, so (0) owns the player for the moment. (0) inform all clients to spawn the player through RPC. When (1) or (2) instantiate the player locally they receive the transformations NetworkViewID per parameter. (1) or (2) assigns this ID to their local players transformation NetworkView and allocate a new NetworkViewID for the input, if this is the own player they want to control.
    This new allocated NetworkViewID will be informed to (0) and updated on (0). Other clients dont need this ID to know. After testing and analyzing this there are no conflicts with the IDs, all clients and the server have the right IDs set. So this is not the problem. The problem I think are the NetworkViews as components.

    I have read the topic "Bringing newly Client Player 'up to Speed'" on http://forum.unity3d.com/viewtopic.php?t=11405 and I think that the problem is also the bug in Unity.

    With resetting the NetworkViews as components I had no luck, but I will try once again...

    So what can I do?
    Where are the experts? Who can tell me how I can bypass this problem or solve it?
     
  2. susdorf

    susdorf

    Joined:
    May 29, 2009
    Posts:
    60
    Hello chucky-x :D ,

    After searching in Unitys examples I found an analogous example in Unity which everyone knows
    and where this situation occurs.

    Looking into Unitys Network Sample "TPS Auth" and try the same Use Case as explained above, you will get the same error, except that this "green thing" has local movement without getting response from server.

    So this is a Unity BUG!!! :cry:

    But I also found out, using "Third Person" Network example, where player is the owner of this "green thing" (Non-Authorative System), everything is fine.

    So can anyone tell me if this bug is known by Unity and if so, when this will be fixed?
     
  3. susdorf

    susdorf

    Joined:
    May 29, 2009
    Posts:
    60
    Dear community,

    after muckracke in Unitys Network System I found a solution:

    To synchronize in an Authorative Server System without having this bug, you have to use RPC. Send clients input to the server and retrieve the transformation of each client from the server. State Synchronization will not work, I have reported this Bug already.

    And be aware of RPCs behaviour, just look at my other topic I have made...

    P.S. I am a smilie fetishist...
     
  4. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    I guess your talking about the bug that occurs when initializing the networkviews yourself? There's a workaround for it, but it's indeed a bug:
    http://forum.unity3d.com/viewtopic.php?p=77193

    This and much more is documented in my unity networking tutorial for UniKnowledge.
     
  5. susdorf

    susdorf

    Joined:
    May 29, 2009
    Posts:
    60
    Thanks for answering.

    Yes I am talking about the situation when allocating NetworkViews yourself. This is unavoidable when doing "bigger projects", especially when new clients can connect to a running game. Instantiating and allocating them automatically by Unity with Network.Instantiate for this Use Case is inappropriate and get out of control when the complexity raises.

    Trying the 4 steps mentionend in "Bringing newly Client Player up to Speed" will not work on my project. Perhaps you see the error, I do following steps on function "OnPlayerConnected":

    1)Spawn player on server and add to list
    2)Spawns already connected player in new connected player(from list)
    3)Spawn new connected player in already connected player

    and new:
    4)ResetNetworkViews for all connected player on server side
    5)ResetNetworkViews player on each client(only own player)


    P.S. Looking at UniKnowledge I could not find a network tutorial that documented "This and much more".
     
  6. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    Have your problems now been fixed?

    Hehe thats great, since mine really does, I just haven't made any documents/examples public yet. Keep an eye out for my entry "Unity networking the zero to hero guide".