You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: com.unity.netcode.gameobjects/Documentation~/components/Helpers/attachablebehaviour.md
+6-8Lines changed: 6 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,9 +20,9 @@ This is simple enough for many scenarios, but can become cumbersome under more s
20
20
With attaching, a user would create nested `GameObject` children that represent the item when it is picked up and when it is dropped/placed somewhere in the scene (i.e. world).<br />
- The WorldItemRoot is where the `NetworkObject` component is placed.
24
-
- The NestedChild-World contains the components needed for the item when it is placed in the world.
25
-
- The NestedChild-PickedUp contains the components needed for the item when it is picked up by a player.
23
+
- The WorldItemRoot is where the `NetworkObject` component is placed.
24
+
- The NestedChild-World contains the components needed for the item when it is placed in the world.
25
+
- The NestedChild-PickedUp contains the components needed for the item when it is picked up by a player.
26
26
27
27
By placing an `AttachableBehaviour` component on the NestedChild-PickedUp `GameObject` and an `AttachableNode` component on the TargetNode, a user can then invoke the `AttachableBehaviour.Attach` method while passing in the `AttachableNode` component and the NestedChild-PickedUp `GameObject` will get parented under the TargetNode while also synchronizing this action with all other clients.<br />
In the diagram above, we see arrows pointing from the `ComponentController` to the non-netcode standard Unity components such as a `MeshRenderer`, `Collider`, or any other component that should only be enabled when either in "World View" or "Attached View" modes. We can also see that the `AttachableBehaviour` points to the `ComponentController` with a diagram to the right that shows the `AttachableBehaviour` notifies the `ComponentController` that, in turn, enables or disables certain components.
128
126
129
127
#### World Item Component Controller
@@ -157,9 +155,9 @@ The above diagram represents what the **Player** and **World Item** spawned obje
Upon a `NetworkObject` component being spawned, all associated `NetworkBehaviour` based component instances, that are directly attached to the `NetworkObject`'s `GameObject` or are on any child `GameObject`, will be registered with the `NetworkObject` instance. This remains true even when a child `GameObject` containing one or more `NetworkBehaviour` based component instances of a spawned `NetworkObject` is parented, during runtime, under another `GameObject` that is associated with a different spawned `NetworkObject`. Of course, there are additional considerations like:
160
-
- What happens when one or both of the NetworkObjects is de-spawned?
161
-
- How do you assure the child attachable will return back to its default parent?
162
-
- and several other edge case scenarios...
158
+
- What happens when one or both of the NetworkObjects is de-spawned?
159
+
- How do you assure the child attachable will return back to its default parent?
160
+
- and several other edge case scenarios...
163
161
164
162
`AttachableBehaviour` leverages from this "spawn lifetime" relationship to provide another type of "parenting" (attaching) while also taking into consideration these types of edge case scenarios.
0 commit comments