Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved [SOLVED]In-Scene placed NetworkObjects are not working.

Discussion in 'Netcode for GameObjects' started by Nitrousek, Oct 19, 2023.

  1. Nitrousek

    Nitrousek

    Joined:
    Jan 31, 2016
    Posts:
    38
    SOLVED - some kind of project corruption going on

    I can't locally join a host, when there is a NetworkObject with a NetworkTransform attached on the scene. It works fine when the NetworkObject doesn't have a NetworkTransform attached. Real-time spawned NetworkObjects work fine too.

    As an attempt at fix, I tried making the in-scene placed object a prefab, as well as adding it to NetworkManager prefabslist, but it didn't help, nor is it necessary as per documentation.

    When NetworkTransform from the NetworkObject is removed, then I can join again. The errors that are thrown don't seem to be informative or even pointing towards this being an issue either.

    Environment:
    • Unity Version: 2023.3.10f1
    • Netcode for GameObjects Version: 1.6.0
    • Unity Transport Version: 2.1.0
    Steps to Reproduce:
    1. New scene
    2. Create a Cube, slap a NetworkObject on it. Add NetworkTransform to it.
    3. Host and try to connect with the build or vice-versa.
    Expected Behavior: Client joins the host
    Actual Behavior: Throws an error, client player doesn't spawn.

    Code (CSharp):
    1. [Netcode] Failed to spawn NetworkObject for Hash 687865857.
    2. 0x00007ff6ef33282d (Unity) StackWalker::GetCurrentCallstack
    3. 0x00007ff6ef3377d9 (Unity) StackWalker::ShowCallstack
    4. 0x00007ff6f0307831 (Unity) GetStacktrace
    5. 0x00007ff6f09c5d52 (Unity) DebugStringToFile
    6. 0x00007ff6ee266db6 (Unity) DebugLogHandler_CUSTOM_Internal_Log
    7. 0x000002b8a4b25fca (Mono JIT Code) (wrapper managed-to-native) UnityEngine.DebugLogHandler:Internal_Log (UnityEngine.LogType,UnityEngine.LogOption,string,UnityEngine.Object)
    8. 0x000002b8a4b25e3b (Mono JIT Code) UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[])
    9. 0x000002b8a4b252be (Mono JIT Code) UnityEngine.Logger:Log (UnityEngine.LogType,object)
    10. 0x000002b8e853fa3a (Mono JIT Code) UnityEngine.Debug:LogError (object)
    11. 0x000002b8e855a213 (Mono JIT Code) Unity.Netcode.NetworkLog:LogError (string) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Logging/NetworkLog.cs:34)
    12. 0x000002b8e8eeda9b (Mono JIT Code) Unity.Netcode.NetworkObject:AddSceneObject (Unity.Netcode.NetworkObject/SceneObject&,Unity.Netcode.FastBufferReader,Unity.Netcode.NetworkManager) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Core/NetworkObject.cs:1552)
    13. 0x000002b8e8eebd6b (Mono JIT Code) Unity.Netcode.SceneEventData:SynchronizeSceneNetworkObjects (Unity.Netcode.NetworkManager) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/SceneManagement/SceneEventData.cs:933)
    14. 0x000002b8e8ed6c8b (Mono JIT Code) Unity.Netcode.NetworkSceneManager:HandleClientSceneEvent (uint) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/SceneManagement/NetworkSceneManager.cs:2048)
    15. 0x000002b8e8edbd73 (Mono JIT Code) Unity.Netcode.NetworkSceneManager:ClientLoadedSynchronization (uint) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/SceneManagement/NetworkSceneManager.cs:1944)
    16. 0x000002b8e8ed9ba3 (Mono JIT Code) Unity.Netcode.NetworkSceneManager:OnClientBeginSync (uint) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/SceneManagement/NetworkSceneManager.cs:1872)
    17. 0x000002b8e8ed6883 (Mono JIT Code) Unity.Netcode.NetworkSceneManager:HandleClientSceneEvent (uint) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/SceneManagement/NetworkSceneManager.cs:2030)
    18. 0x000002b8e8e9fc13 (Mono JIT Code) Unity.Netcode.NetworkSceneManager:HandleSceneEvent (ulong,Unity.Netcode.FastBufferReader) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/SceneManagement/NetworkSceneManager.cs:2268)
    19. 0x000002b8e8eafc7b (Mono JIT Code) Unity.Netcode.SceneEventMessage:Handle (Unity.Netcode.NetworkContext&) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Messaging/Messages/SceneEventMessage.cs:26)
    20. 0x000002b8e8ecfcf3 (Mono JIT Code) Unity.Netcode.NetworkMessageManager:ReceiveMessage<Unity.Netcode.SceneEventMessage> (Unity.Netcode.FastBufferReader,Unity.Netcode.NetworkContext&,Unity.Netcode.NetworkMessageManager) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Messaging/NetworkMessageManager.cs:567)
    21. 0x000002b8e8ec380f (Mono JIT Code) (wrapper delegate-invoke) <Module>:invoke_void_FastBufferReader_NetworkContext&_NetworkMessageManager (Unity.Netcode.FastBufferReader,Unity.Netcode.NetworkContext&,Unity.Netcode.NetworkMessageManager)
    22. 0x000002b8e8ec0aae (Mono JIT Code) Unity.Netcode.NetworkMessageManager:HandleMessage (Unity.Netcode.NetworkMessageHeader&,Unity.Netcode.FastBufferReader,ulong,single,int) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Messaging/NetworkMessageManager.cs:432)
    23. 0x000002b8e8e6b7e3 (Mono JIT Code) Unity.Netcode.NetworkMessageManager:ProcessIncomingMessageQueue () (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Messaging/NetworkMessageManager.cs:458)
    24. 0x000002b8e8e65203 (Mono JIT Code) Unity.Netcode.NetworkManager:NetworkUpdate (Unity.Netcode.NetworkUpdateStage) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Core/NetworkManager.cs:42)
    25. 0x000002b8a4be9aac (Mono JIT Code) Unity.Netcode.NetworkUpdateLoop:RunNetworkUpdateStage (Unity.Netcode.NetworkUpdateStage) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Core/NetworkUpdateLoop.cs:185)
    26. 0x000002b8a4c220f3 (Mono JIT Code) Unity.Netcode.NetworkUpdateLoop/NetworkEarlyUpdate/<>c:<CreateLoopSystem>b__0_0 () (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Core/NetworkUpdateLoop.cs:208)
    27. 0x000002b8a591bc58 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
    28. 0x00007ff99966e274 (mono-2.0-bdwgc) mono_jit_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/mini/mini-runtime.c:3445)
    29. 0x00007ff9995aeb74 (mono-2.0-bdwgc) do_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/metadata/object.c:3066)
    30. 0x00007ff9995aed0c (mono-2.0-bdwgc) mono_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/metadata/object.c:3113)
    31. 0x00007ff6ef249d14 (Unity) scripting_method_invoke
    32. 0x00007ff6ef227e34 (Unity) ScriptingInvocation::Invoke
    33. 0x00007ff6eeec3728 (Unity) ExecutePlayerLoop
    34. 0x00007ff6eeec3748 (Unity) ExecutePlayerLoop
    35. 0x00007ff6eeeca025 (Unity) PlayerLoop
    36. 0x00007ff6efe8c16f (Unity) PlayerLoopController::InternalUpdateScene
    37. 0x00007ff6efe98d9d (Unity) PlayerLoopController::UpdateSceneIfNeededFromMainLoop
    38. 0x00007ff6efe970a1 (Unity) Application::TickTimer
    39. 0x00007ff6f030e16a (Unity) MainMessageLoop
    40. 0x00007ff6f03139d0 (Unity) WinMain
    41. 0x00007ff6f16f7dbe (Unity) __scrt_common_main_seh
    42. 0x00007ff9d5fb7034 (KERNEL32) BaseThreadInitThunk
    43. 0x00007ff9d77c26a1 (ntdll) RtlUserThreadStart
    44.  
    Code (CSharp):
    1. OverflowException: Reading past the end of the buffer
    2. Unity.Netcode.FastBufferReader.ReadBytesSafe (System.Byte* value, System.Int32 size, System.Int32 offset) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Serialization/FastBufferReader.cs:715)
    3. Unity.Netcode.FastBufferReader.ReadUnmanagedSafe[T] (T& value) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Serialization/FastBufferReader.cs:769)
    4. Unity.Netcode.FastBufferReader.ReadValueSafe[T] (T& value, Unity.Netcode.FastBufferWriter+ForPrimitives unused) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Serialization/FastBufferReader.cs:1108)
    5. Unity.Netcode.NetworkObject+SceneObject.Deserialize (Unity.Netcode.FastBufferReader reader) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Core/NetworkObject.cs:1336)
    6. Unity.Netcode.SceneEventData.SynchronizeSceneNetworkObjects (Unity.Netcode.NetworkManager networkManager) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/SceneManagement/SceneEventData.cs:926)
    7. Unity.Netcode.NetworkSceneManager.HandleClientSceneEvent (System.UInt32 sceneEventId) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/SceneManagement/NetworkSceneManager.cs:2048)
    8. Unity.Netcode.NetworkSceneManager.ClientLoadedSynchronization (System.UInt32 sceneEventId) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/SceneManagement/NetworkSceneManager.cs:1944)
    9. Unity.Netcode.NetworkSceneManager.OnClientBeginSync (System.UInt32 sceneEventId) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/SceneManagement/NetworkSceneManager.cs:1872)
    10. Unity.Netcode.NetworkSceneManager.HandleClientSceneEvent (System.UInt32 sceneEventId) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/SceneManagement/NetworkSceneManager.cs:2030)
    11. Unity.Netcode.NetworkSceneManager.HandleSceneEvent (System.UInt64 clientId, Unity.Netcode.FastBufferReader reader) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/SceneManagement/NetworkSceneManager.cs:2268)
    12. Unity.Netcode.SceneEventMessage.Handle (Unity.Netcode.NetworkContext& context) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Messaging/Messages/SceneEventMessage.cs:26)
    13. Unity.Netcode.NetworkMessageManager.ReceiveMessage[T] (Unity.Netcode.FastBufferReader reader, Unity.Netcode.NetworkContext& context, Unity.Netcode.NetworkMessageManager manager) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Messaging/NetworkMessageManager.cs:567)
    14. Unity.Netcode.NetworkMessageManager.HandleMessage (Unity.Netcode.NetworkMessageHeader& header, Unity.Netcode.FastBufferReader reader, System.UInt64 senderId, System.Single timestamp, System.Int32 serializedHeaderSize) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Messaging/NetworkMessageManager.cs:432)
    15. UnityEngine.Debug:LogException(Exception)
    16. Unity.Netcode.NetworkMessageManager:HandleMessage(NetworkMessageHeader&, FastBufferReader, UInt64, Single, Int32) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Messaging/NetworkMessageManager.cs:436)
    17. Unity.Netcode.NetworkMessageManager:ProcessIncomingMessageQueue() (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Messaging/NetworkMessageManager.cs:458)
    18. Unity.Netcode.NetworkManager:NetworkUpdate(NetworkUpdateStage) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Core/NetworkManager.cs:42)
    19. Unity.Netcode.NetworkUpdateLoop:RunNetworkUpdateStage(NetworkUpdateStage) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Core/NetworkUpdateLoop.cs:185)
    20. Unity.Netcode.<>c:<CreateLoopSystem>b__0_0() (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Core/NetworkUpdateLoop.cs:208)
    21.  
     
    Last edited: Oct 20, 2023
  2. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    638
    I tried this with Unity 2023.1.17f1, Netcode 1.6.0 and Unity Transport 2.1.0 and I'm not seeing the issue, only the host was a build and the client run in the editor.
     
  3. Nitrousek

    Nitrousek

    Joined:
    Jan 31, 2016
    Posts:
    38
    Seems to be some kind of incompatibility on my end, as it works in a fresh project.