-
-
Notifications
You must be signed in to change notification settings - Fork 190
Description
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:
RemoveOwnershipis never called.- The
NetworkObjects involved are both on the root level.
Replication
Steps to reproduce the behavior:
-
Create the following NetworkObjects, in this hierarchy:
-- MainParent (NetworkObject)
---- Square (NetworkObject,PredictedOwner,NetworkTransform(Synchronize Parent ☑))
---- Circle (NetworkObject,PredictedOwner,NetworkTransform(Synchronize Parent ☑)) -
Using default NetworkManager, load the scene as
Host(Start Server, Start Client) -
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)
-
Observe that Circle is indeed now nested within Sqaure.
-
However, Observe error:
Already contains Circle -
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
