Search Unity

Bug: SyncListFloat Crashes NetworkAnimator

Discussion in 'Multiplayer' started by Zullar, Oct 15, 2015.

  1. Zullar

    Zullar

    Joined:
    May 21, 2013
    Posts:
    651
    The Bug:
    During scene loading on the localClient (not the host) a GameObject will bug out with the error below *if* there is an additional NetworkBehaviour script attached to the same GameObject that is lower in the hierarchy and also contains a SyncListFloat. This bug causes all networked SceneObjects not to spawn and breaks the scene.

    Code To Replicate:
    Using 5.2.1f1
    NetworkBehaviour script
    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4. using UnityEngine.Networking; //needed for NetworkBehaviorStatIndividual
    5.  
    6. public class TestNetAnimBug : NetworkBehaviour
    7. {
    8.     public SyncListFloat syncListFloat = new SyncListFloat();
    9. }
    10.  
    GameObject Heirarchy
    NetworkAnimator Bug.png

    Other Observations
    -If I remove the NetworkAnimator then everything works fine.
    -If I remove the SyncListFloat from the script then everything works fine.
    -If I move the NetworkAnimator component lower in the hierarchy than the NetworkBehaviour script the bug does not occur.
    -It seems the bug is related to the NetworkServer.SpawnObjects() call. I'm using a CustomNetworkManager : NetworkManager and for some reason NetworkServer.SpawnObjects() isn't automatically called, so I call it manually after server OnLevelWasLoaded()... and this call drives the error (If I comment out the NetworkServer.SpawnObjects() then I get no error, but also the client objects are not enabled/spawned) .

    Error
    IndexOutOfRangeException: NetworkReader:ReadByte out of range:NetBuf sz:18 pos:18
    UnityEngine.Networking.NetBuffer.ReadByte () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkBuffer.cs:35)
    UnityEngine.Networking.NetworkReader.ReadUInt32 () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkReader.cs:198)
    UnityEngine.Networking.NetworkReader.ReadSingle () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkReader.cs:270)
    UnityEngine.Networking.SyncListFloat.ReadInstance (UnityEngine.Networking.NetworkReader reader) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/SyncList.cs:60)
    TestNetAnimBug.OnDeserialize (UnityEngine.Networking.NetworkReader reader, Boolean initialState)
    UnityEngine.Networking.NetworkIdentity.OnUpdateVars (UnityEngine.Networking.NetworkReader reader, Boolean initialState) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkIdentity.cs:623)
    UnityEngine.Networking.ClientScene.ApplySpawnPayload (UnityEngine.Networking.NetworkIdentity uv, Vector3 position, System.Byte[] payload, NetworkInstanceId netId, UnityEngine.GameObject newGameObject) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/ClientScene.cs:388)
    UnityEngine.Networking.ClientScene.OnObjectSpawnScene (UnityEngine.Networking.NetworkMessage netMsg) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/ClientScene.cs:499)
    UnityEngine.Networking.NetworkConnection.HandleReader (UnityEngine.Networking.NetworkReader reader, Int32 receivedSize, Int32 channelId) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkConnection.cs:416)
    UnityEngine.Networking.NetworkConnection.HandleBytes (System.Byte[] buffer, Int32 receivedSize, Int32 channelId) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkConnection.cs:372)
    UnityEngine.Networking.NetworkConnection.TransportRecieve (System.Byte[] bytes, Int32 numBytes, Int32 channelId) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkConnection.cs:522)
    UnityEngine.Networking.NetworkClient.Update () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkClient.cs:554)
    UnityEngine.Networking.NetworkClient.UpdateClients () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkClient.cs:768)
    UnityEngine.Networking.NetworkIdentity.UNetStaticUpdate () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkIdentity.cs:899)
     
  2. _Adriaan

    _Adriaan

    Joined:
    Nov 12, 2009
    Posts:
    481
    Definitely post these kinds of bugs using the bug reporting tool - the forum is mainly for questions and discussion.
     
    Zullar likes this.
  3. Zullar

    Zullar

    Joined:
    May 21, 2013
    Posts:
    651
    ok, thanks
     
  4. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    981
    And while you're at it, try patching to 5.2.1p4 and see if the bug is still there.
     
  5. Zullar

    Zullar

    Joined:
    May 21, 2013
    Posts:
    651
    Last edited: Nov 23, 2015
  6. Yosefgabar

    Yosefgabar

    Joined:
    Apr 16, 2015
    Posts:
    1
    Hello can u guys help me?
    I'm making a network animator, and when u start my game, when u try to control a player the animations plays in all of the players in the game.