Search Unity

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

Resolved [Netcode] NetworkObject children not resolved to parents by the end of frame

Discussion in 'Netcode for GameObjects' started by alexooro, Nov 17, 2023.

  1. alexooro

    alexooro

    Joined:
    May 26, 2020
    Posts:
    11
    Hi,

    After I switch scenes I spawn a few NetworkObjects on the host, they seem to spawn as normal but while playing as the client I get these warnings.

    View attachment 1332616

    NetworkObject (5) is the client player prefab,
    NetworkObject (31) is one of many chair objects,
    NetworkObject (40) is one of many table objects

    All of these object prefabs are registered in the NetworkManager, they spawn on the client and seem to work fine, and as stated above, these are only a few of many NetworkObjects and which ones give the warning seem to vary between sessions.

    What does these warnings mean and what is the reason for them?
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,066
  3. NoelStephens_Unity

    NoelStephens_Unity

    Unity Technologies

    Joined:
    Feb 12, 2022
    Posts:
    244
    Well, this might be one of two things.

    Thing #1: There was a recent fix (PR-2735) applied to NGO v1.7.0 that resolved an issue where if a client was loading a scene (LoadSceneMode.Single) and received one or more CreateObjectMessages (i.e. spawn object) and the client had not finished loading the new scene, then the newly spawned NetworkObjects could get instantiated in the current scene that would get unloaded when the new scene finished loading. If you are running an earlier version of NGO (than v1.7.0), then this could very well be what is happening if the NetworkObjects you spawned are getting parented under something after they are spawned on the host-server side.
    One way to verify that this is happening is to look at the client log and see if it received any messages similar to:
    Thing #2: If the scene is relatively large and the scene loading (client-side) takes more than 1 second (and I mean even something like 1.03333 seconds), then any message (i.e. parenting, spawning, etc.) that could be targeting a NetworkObject in the new scene being loaded get placed into a "deferred queue" to wait for the NetworkObject(s) to get spawned. If it takes longer than the configured NetworkManager.NetworkConfig.SpawnTimeout value (which currently defaults to 1 second...and we will be updating that soon to default to a higher value), then those deferred messages will get dropped/ignored. So, you can also try increasing the SpawnTimeout value to something like 10-20 seconds (on the client-side) to hold onto any pending messages long enough for the scene to completely load.
    One way to verify that this is happening is to look at the client log and see if it received any messages similar to:
     
    alexooro likes this.
  4. alexooro

    alexooro

    Joined:
    May 26, 2020
    Posts:
    11
    Thing #1 seems to have been the issue, although I couldn't verify it by the log example provided as I did not get any other messages than the ones I showed earlier.

    I was able to solve the issue by waiting for all the clients to load into the scene before spawning any NetworkObjects.

    Thank you for your help.
     
  5. NoelStephens_Unity

    NoelStephens_Unity

    Unity Technologies

    Joined:
    Feb 12, 2022
    Posts:
    244
    Ahh... well glad one of the two things that came to mind help you get past your issue.
    ;)
    Happy net-coding!
     
    alexooro likes this.