Skip to content

NetworkRigidbody2D throws NullReferenceException on spawn when Rigidbody2D interpolation is Extrapolate #3924

Closed

Description

@ercantomac

Description

I ran into a reproducible NullReferenceException when using NetworkRigidbody2D with a Rigidbody2D whose interpolation mode is set to Extrapolate.

This happens during multiplayer spawning on the non-owner/client side. Changing the same Rigidbody2D interpolation setting from Extrapolate to Interpolate makes the issue disappear immediately.

This makes it look like a package bug in NGO rather than a project-side null reference.

Versions

  • Netcode for GameObjects: 2.11.0
  • Unity Transport: 2.6.0
  • Multiplayer Services: 2.0.0

Reproduction Steps

  1. Create a networked prefab with:
    • NetworkObject
    • NetworkTransform
    • Rigidbody2D
    • NetworkRigidbody2D
  2. Set the prefab's Rigidbody2D.interpolation to Extrapolate.
  3. Spawn the prefab in a multiplayer session (in my case as a player object).
  4. Connect a client / let the non-owner instance spawn.

Expected Result

The object should spawn normally, and NGO should handle NetworkRigidbody2D without errors.

Actual Result

A NullReferenceException is thrown during spawn/initialization.

Stack Trace

NullReferenceException: Object reference not set to an instance of an object
Unity.Netcode.Components.NetworkRigidbodyBase.UpdateOwnershipAuthority () (at ./Library/PackageCache/com.unity.netcode.gameobjects@02e4aaa4170c/Runtime/Components/NetworkRigidBodyBase.cs:993)
Unity.Netcode.Components.NetworkTransform.InternalInitialization (System.Boolean isOwnershipChange) (at ./Library/PackageCache/com.unity.netcode.gameobjects@02e4aaa4170c/Runtime/Components/NetworkTransform.cs:3743)
Unity.Netcode.Components.NetworkTransform.Initialize () (at ./Library/PackageCache/com.unity.netcode.gameobjects@02e4aaa4170c/Runtime/Components/NetworkTransform.cs:3809)
Unity.Netcode.Components.NetworkTransform.OnNetworkSpawn () (at ./Library/PackageCache/com.unity.netcode.gameobjects@02e4aaa4170c/Runtime/Components/NetworkTransform.cs:3612)
Unity.Netcode.NetworkBehaviour.NetworkSpawn () (at ./Library/PackageCache/com.unity.netcode.gameobjects@02e4aaa4170c/Runtime/Core/NetworkBehaviour.cs:814)

Workaround

Changing Rigidbody2D.interpolation from Extrapolate to Interpolate fixes the problem.

Additional Notes

While investigating this locally, I noticed code in NetworkRigidBodyBase that appears to access the 3D rigidbody field during the extrapolation path:

if (UseRigidBodyForMotion)
{
    if (NetworkTransform.Interpolate && m_OriginalInterpolation == InterpolationTypes.Extrapolate)
    {
        if (IsKinematic())
        {
            if (m_InternalRigidbody.interpolation == RigidbodyInterpolation.Extrapolate)

For NetworkRigidbody2D, this looks suspicious because the 2D path should not be relying on m_InternalRigidbody.

Activity

  1. EmandM commented on Mar 30, 2026

    @EmandM
    Member

    Thanks for reporting this with all these details. I'll import this to be fixed!

  2. added
    stat:importStatus - Issue is going to be saved internally
    and removed on Mar 30, 2026
  3. removed
    stat:awaiting-responseAwaiting response from author. This label should be added manually.
    stat:awaiting-triageStatus - Awaiting triage from the Netcode team.
    on Mar 30, 2026
  4. added
    stat:importedStatus - Issue is tracked internally at Unity
    and removed
    stat:importStatus - Issue is going to be saved internally
    on Apr 20, 2026
  5. NoelStephensUnity commented on Jun 8, 2026

    @NoelStephensUnity
    Member

    Hi @ercantomac,

    We are getting the fix for this in place. It should be in the next update (that proceeds v2.12.0).

  6. removed
    stat:awaiting-responseAwaiting response from author. This label should be added manually.
    on Jun 9, 2026
  7. NoelStephensUnity commented on Jun 22, 2026

    @NoelStephensUnity
    Member

    #4012 resolves this issue and will be in the next update.

  8. NoelStephensUnity commented on Jun 22, 2026

    @NoelStephensUnity
    Member

    The fix for this should be in v2.13.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stat:importedStatus - Issue is tracked internally at Unitytype:bugBug Report

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions