Recently I have been using the Mirror networking library to design a multiplayer card game however I have stumbled into a problem with syncing an int (32 bits) variable which I am using as a bitmask. When I try to manipulate the int variable I get the error message below. What stuck out to me was the warning “Maybe this OnDeserialize call was meant for another GameObject? The sceneIds can easily get out of sync if the Hierarchy was modified only in the client OR the server. Try rebuilding both.
” I know that I have been moving objects around that have network behaviours attached to them (but not network transforms). Any ideas if this is the cause?
OnDeserialize failed for: object=Card Temp(Clone) component=CardInstance sceneId=0 length=4. Possible Reasons:
* Do CardInstance's OnSerialize and OnDeserialize calls write the same amount of data(4 bytes)?
* Was there an exception in CardInstance's OnSerialize/OnDeserialize code?
* Are the server and client the exact same project?
* Maybe this OnDeserialize call was meant for another GameObject? The sceneIds can easily get out of sync if the Hierarchy was modified only in the client OR the server. Try rebuilding both.
Exeption System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) [0x00029] in <437ba245d8404784b9fbab9b439ac908>:0
at System.ThrowHelper.ThrowArgumentOutOfRangeException () [0x00000] in <437ba245d8404784b9fbab9b439ac908>:0
at System.Collections.Generic.List`1[T].get_Item (System.Int32 index) [0x00009] in <437ba245d8404784b9fbab9b439ac908>:0
at CardInstance.CardLocationChangeHook (System.Int32 oldLocation, System.Int32 newLocation) [0x0008e] in C:\Users\MrMir\Desktop\Unity Projects\Business Card Game\Assets\Scripts\CardLogic\CardInstance.cs:68
at CardInstance.DeserializeSyncVars (Mirror.NetworkReader reader, System.Boolean initialState) [0x00154] in <2cc28671634342828f39750f8191ca59>:0
at Mirror.NetworkBehaviour.OnDeserialize (Mirror.NetworkReader reader, System.Boolean initialState) [0x0001c] in C:\Users\MrMir\Desktop\Unity Projects\Business Card Game\Assets\Mirror\Runtime\NetworkBehaviour.cs:595
at Mirror.NetworkIdentity.OnDeserializeSafely (Mirror.NetworkBehaviour comp, Mirror.NetworkReader reader, System.Boolean initialState) [0x0008b] in C:\Users\MrMir\Desktop\Unity Projects\Business Card Game\Assets\Mirror\Runtime\NetworkIdentity.cs:944
UnityEngine.Logger:Log(LogType, Object)
Mirror.ILoggerExtensions:LogError(ILogger, Object) (at Assets/Mirror/Runtime/Logging/LogFactory.cs:82)
Mirror.NetworkIdentity:OnDeserializeSafely(NetworkBehaviour, NetworkReader, Boolean) (at Assets/Mirror/Runtime/NetworkIdentity.cs:949)
Mirror.NetworkIdentity:OnDeserializeAllSafely(NetworkReader, Boolean) (at Assets/Mirror/Runtime/NetworkIdentity.cs:983)
Mirror.ClientScene:OnUpdateVarsMessage(UpdateVarsMessage) (at Assets/Mirror/Runtime/ClientScene.cs:961)
Mirror.<>c__DisplayClass31_0`1:<RegisterHandler>b__0(NetworkConnection, UpdateVarsMessage) (at Assets/Mirror/Runtime/NetworkClient.cs:331)
Mirror.<>c__DisplayClass7_0`2:<MessageHandler>b__0(NetworkConnection, NetworkReader, Int32) (at Assets/Mirror/Runtime/MessagePacker.cs:148)
Mirror.NetworkConnection:InvokeHandler(Int32, NetworkReader, Int32) (at Assets/Mirror/Runtime/NetworkConnection.cs:225)
Mirror.NetworkConnection:TransportReceive(ArraySegment`1, Int32) (at Assets/Mirror/Runtime/NetworkConnection.cs:278)
Mirror.NetworkClient:OnDataReceived(ArraySegment`1, Int32) (at Assets/Mirror/Runtime/NetworkClient.cs:172)
UnityEngine.Events.UnityEvent`2:Invoke(ArraySegment`1, Int32)
Mirror.TelepathyTransport:ProcessClientMessage() (at Assets/Mirror/Runtime/Transport/TelepathyTransport.cs:102)
Mirror.TelepathyTransport:LateUpdate() (at Assets/Mirror/Runtime/Transport/TelepathyTransport.cs:136)