Skip to content

SetParent() on nested NetworkObject appears to work, but logs errors, when using PredictedOwner #906

@curiousdustin

Description

@curiousdustin

General
Unity version: 6000.0.41f1
Fish-Networking version: 4.6.7hf0R, 4.67.8R
Discord link: NetworkObject.SetParent() after PredictedOwner.TakeOwnership() causes Already Contains X errors

Screen Recording: Video
Sample Project: SetParentErrors.unitypackage.zip

Description
When PredictedOwner is used to TakeOwnership of a NetworkObject that is nested within another NetworkObject, SetParent is used to change the nesting, and RemoveOwnership is used to return ownership to the server, Already contains errors are logged even though the behavior seems to continue as expected.

These errors do not occur if either:

  • RemoveOwnership is never called.
  • The NetworkObjects involved are both on the root level.

Replication
Steps to reproduce the behavior:

  1. Create the following NetworkObjects, in this hierarchy:
    -- MainParent (NetworkObject)
    ---- Square (NetworkObject, PredictedOwner, NetworkTransform (Synchronize Parent ☑))
    ---- Circle (NetworkObject, PredictedOwner, NetworkTransform (Synchronize Parent ☑))

  2. Using default NetworkManager, load the scene as Host (Start Server, Start Client)

  3. At runtime, execute the following code bits in order:

[ServerRpc(RequireOwnership = false)]
public void RpcReturnOwnershipToServer()
{
    RemoveOwnership();
}

// In my case, to start dragging an object
Circle.predictedOwner.TakeOwnership(true);

// In my case, when object is dropped on top of Sqaure
Circle.NetworkObject.SetParent(Square.NetworkObject);

// In my case, called immediately after SetParent
Circle.RpcReturnOwnershipToServer(); (Calls RemoveOwnership on Server)
  1. Observe that Circle is indeed now nested within Sqaure.

  2. However, Observe error:
    Already contains Circle

  3. Observe similar error every time SetParent is called on either Square or Circle from here on.

Expected behavior
On the surface, the actual behavior appears to be fine. But I would expect no error to be logged.

Screenshots

Image Image Image Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolved Pending ReleaseIssue is resolved and will be available on the noted version.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions