A robust solution for parenting network objects under deeply nested GameObjects in Unity Netcode for GameObjects with Distributed Authority topology.
Recording.2025-08-02.205544.mp4
- ✨ Deep Nesting Support: Parent network objects to deeply nested child GameObjects
- 🔄 Automatic Synchronization: All clients receive parenting changes automatically
- 🕐 Late Join Support: Players joining mid-game see correct object hierarchy
- 🎯 Simple API: One method call to parent any network object
- 🏗️ Distributed Authority: Designed for distributed authority network topology
- Unity Netcode for GameObjects
- Network Manager with Distributed Authority topology
- Target network objects must have Auto Object Parent Sync turned OFF
- Network objects to be parented must have Ownership set to None
Attach the NetworkParentCentre component to the root GameObject of your network object (e.g., Player):
Player (Network Object) ← NetworkParentCentre goes here
├── Arm (child)
│ └── Hand (child) ← NetworkParent goes here
└── Other components...
Add NetworkParent components to any child GameObject where you want to enable parenting:
// On the Hand GameObject
NetworkParent networkParent = handGameObject.GetComponent<NetworkParent>();
networkParent.NetworkParentId = "Object Holder Network Parent";Use the simple API to parent any spawned network object:
// Get reference to the Network Parent Centre
NetworkParentCentre parentCentre = playerGameObject.GetComponent<NetworkParentCentre>();
// Parent the network item (e.g., weapon) to the specified parent
bool success = parentCentre.TryToParentNetworkObject(weaponNetworkObject, "Object Holder Network Parent");Perfect for scenarios like:
- 🗡️ Weapon Systems: Parenting weapons to player hands
- 📦 Inventory Items: Attaching items to specific body parts
- 🎒 Equipment: Mounting gear to character attachment points
- 🚗 Vehicle Interactions: Placing objects inside vehicles
| Setting | Value | Location |
|---|---|---|
| Network Manager Topology | Distributed Authority |
Network Manager |
| Auto Object Parent Sync | OFF |
Network Object to be parented |
| Object Ownership | None |
Network Object to be parented |
public bool TryToParentNetworkObject(NetworkObjectReference networkObjectReference, string networkParentId)Parameters:
networkObjectReference: The network object to be parentednetworkParentId: The identifier of the target parent
Returns: bool - Success status of the parenting operation
public string NetworkParentId; // Set this to identify the parent location- Initialization:
NetworkParentCentrediscovers allNetworkParentcomponents in children - Parenting Request: Call
TryToParentNetworkObject()with target object and parent ID - Local Parenting: Object is immediately parented locally on the owner
- Network Sync:
ClientRpcsynchronizes the parenting across all clients - Late Join Support: New clients automatically receive the correct hierarchy
⚠️ Only the owner of the NetworkParentCentre can initiate parenting operations- 🏗️ NetworkParentCentre must be on a root GameObject (no parent)
- 🔒 Target network objects must have ownership set to None
- 📴 Ensure Auto Object Parent Sync is disabled on objects to be parented

