Bug: SyncListFloat Crashes NetworkAnimator

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

using UnityEngine;
using System.Collections;
using UnityEngine.Networking; //needed for NetworkBehaviorStatIndividual

public class TestNetAnimBug : NetworkBehaviour
{
    public SyncListFloat syncListFloat = new SyncListFloat();
}

GameObject Heirarchy
2339683--158196--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)

Definitely post these kinds of bugs using the bug reporting tool - the forum is mainly for questions and discussion.

1 Like

ok, thanks

And while you’re at it, try patching to 5.2.1p4 and see if the bug is still there.

Edit: This entire thread is misleading and I drew the wrong conclusion. It seems this issue of SceneObjects not spawning is mostly due to custom NetworkManager overriding the default Awake() initialization and causing various bugs, including SceneObjects not spawning. I made a new corrected post here.

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.