Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Bug NullReference NetworkTransform line 3067

Discussion in 'Netcode for GameObjects' started by BlocCole, Apr 11, 2024.

  1. BlocCole

    BlocCole

    Joined:
    Jun 29, 2023
    Posts:
    1
    Hi all,

    Unsure what caused this to happen but suddenly when playing the networked VR app im making, im getting the error:

    NullReferenceException: Object reference not set to an instance of an object
    Unity.Netcode.Components.NetworkTransform.UpdateInterpolation () (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.8.1/Components/NetworkTransform.cs:3067)

    Line 3067 is this: var serverTime = m_CachedNetworkManager.ServerTime; which im guessing that the reference to the networkmanager is null. Its for interpolation which I would prefer to keep on.

    The network transforms that are causing this are on my network player on child objects the layout is:

    Network Player (has Network object and network transform)
    ----Head (Has network transform)
    ----Left Controller (Has network transform)
    ----Right Controller (Has network transform)
    ----Left Hand (Has network transform)
    ----Right Hand (Has network transform)
    ----PC

    And all of the network transforms on this network player is having this error apart from the parent. Unsure what it causing this to happen any suggestions for fixes would be great,

    Thank you for any replies.

    Edit: it only seems to happen in the editor and not in any of the builds

    2nd Edit: I cant reproduce this issue anymore, unsure as to why as I haven't changed anything, if this happens again ill comment on this post

    3rd Edit: Its back again and this time on builds aswell

    Solution:
    Make sure the gameobject is not being disabled on start, wish the error was caught rather than giving me a random line in the interpolation code but for anyone who has this issue check that you're not doing that. If you have multiple different types of players in my case for different platforms I would suggest not using the playerprefab in networkmanager rather make your own playermanager with different player prefabs
     
    Last edited: Apr 15, 2024