Skip to content
This repository was archived by the owner on Jul 23, 2025. It is now read-only.
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions docs/advanced-topics/networkobject-parenting.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,31 @@ If you aren't completely familiar with transform parenting in Unity, then it's h
- When `OnNetworkObjectParentChanged` is invoked, on the server side, adjust the child's transform values within the overridden method.
- Netcode for GameObjects will then synchronize all clients with the child's parenting and transform changes.

### Parenting, Distributed Authority, and NetworkObject Redistribution

Parenting within a distributed authority network topology follows the same rules as outlined above with the minor exception that you can exchange any references to "server" with "authority".
#### Rules Adjustments:
- Whoever has authority of a `NewtworkObject` can control its parenting.
- You can parent under mixed authority. This means Client-B can parent a `NetworkObject` it has authority over under another `NetworkObject` that Client-A has authority over.

#### Distributable Permissions and Child Hierarchies:
- **Upon a client disconnecting:**
- Any root parent with distributable permission set and was owned by the client that disconnected will be redistributed.
- If the root parent was locked when the client disconnected, then it will be unlocked prior to redistributing.
- All children under the root parent will "follow" the root parent ownership change only if:
- The child is owned by the client that disconnected.
- The child has either the distributable or transferable permission set.
- If a child's ownership permission is locked, it will be unlocked prior to redistributing.
- Any child of the root parent that is owned by a different client will not get redistributed.
- **Upon a client connecting:**
- Any root parent with the distributable permission set and does not have ownership locked will be taken into consideration for redistribution.
- If a root parent is redistributed to a newly connecting client then:
- Any child under the root parent that has the same owner as the root parent will "follow" (*i.e. change ownership with the root parent*).
- Unless the child has ownership locked (i.e. it will not have its ownership changed).
- Any child under the root parent that has the distributable or transferrable permission set can be redistributed as well.
- Unless the child has ownership locked (i.e. it will not have its ownership changed).


:::tip
When a NetworkObject is parented, Netcode for GameObjects synchronizes both the parenting information along with the child's transform values. Netcode for GameObjects uses the `WorldPositionStays` setting to decide whether to synchronize the local or world space transform values of the child NetworkObject component. This means that a NetworkObject component doesn't require you to include a NetworkTransform component if it never moves around, rotates, or changes its scale when it isn't parented. This can be beneficial for world items a player might pickup (parent the item under the player) and the item in question needs to adjustment relative to the player when it's parented or the parent is removed (dropped). This helps to reduce the item's over-all bandwidth and processing resources consumption.
:::
Expand Down