-
Notifications
You must be signed in to change notification settings - Fork 216
Add Boss Room educational content #827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
fbab318
Add new Boss Room educational content
armstrongl cecd664
Update sidebar
armstrongl f7e845b
Update docs/learn/bossroom/networkobject-parenting.md
74b8a5a
Update docs/learn/bossroom/networkobject-parenting.md
9a682c2
Update docs/learn/bossroom/networkobject-parenting.md
6d91170
Update docs/learn/bossroom/networkrigidbody.md
46e56f3
Update docs/learn/bossroom/networkrigidbody.md
cd2921f
Merge branch 'develop' into boss-room-edu-content
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
id: networkobject-parenting | ||
title: NetworkObject Parenting inside Boss Room | ||
description: Learn about Boss Room's approach to NetworkObject parenting. | ||
--- | ||
:::note | ||
Required reading: [NetworkObject Parenting](../../advanced-topics/networkobject-parenting.md) | ||
::: | ||
|
||
Before detailing Boss Room’s approach toon `NetworkObject` parenting, it’s important to highlight a limitation of Netcode: A dynamically-spawned `NetworkObject` **cannot** contain another `NetworkObject` in its hierarchy. If you spawn such a `NetworkObject` is spawned, you cannot spawn children `NetworkObjects` will not be spawned. You can only add multiple `NetworkObject` components to a `NetworkObject` that is part of a scene. | ||
armstrongl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Inside Boss Room leverages, `NetworkObject` parenting is leveraged through the server-driven `PickUp` action (see [`PickUpAction.cs`](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/Action/ConcreteActions/PickUpAction.cs)), where a character has the ability to pick up a specially-tagged, in-scene placed `NetworkObject` (see [`PickUpPot` prefab](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Prefabs/Game/PickUpPot.prefab)]. | ||
armstrongl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
At its root, `PickUpPot` contains a `NetworkObject`, a `NetworkTransform`, and a `PositionConstraint` component. `AutoObjectParentSync` is enabled on its `NetworkTransform` (as is by default) so that: | ||
|
||
1. `NetworkObject` can verify server-side if parenting a Heavy object to another `NetworkObject` is allowed. | ||
2. `NetworkObject` can notify us when the parent has successfully been modified server-side. | ||
armstrongl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
To accommodate the limitation highlighted at the beginning of this document, Boss Room leverages the `PositionConstraint` component to simulate an object following a character’s position. | ||
|
||
A special hand bone has been added to our Character’s avatar. Upon a character’s successful parenting attempt, this special bone is set as the `PickUpPot`’s `PositonConstraint` target. So while the `PickUpPot` is technically parented to a player, the `PositionConstraint` component allows the `PickUpPot` to follow a bone’s position, presenting the **illusion** that the `PickUpPot` is parented to the player’s hand bone itself. | ||
|
||
Once the `PickUpPot` is parented, local space simulation is enabled on its [`NetworkTransform` component](../../components/networktransform.md). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
id: networkrigidbody | ||
title: NetworkRigidbody inside Boss Room | ||
description: Learn how Boss Room leverages NetworkRigidbody. | ||
--- | ||
:::note | ||
Required reading: [Physics](../..//advanced-topics/physics.md) | ||
::: | ||
|
||
Inside Boss Room leverages, `NetworkRigidbody` has been leveraged to simulate physics-based projectiles. See the Vandal Imp’s tossed projectile, the [`ImpTossedItem` prefab](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Prefabs/Game/ImpTossedItem.prefab). At its root, this prefab contains at its root a `NetworkObject`, a `NetworkTransform`, a `Rigidbody`, and a `NetworkRigidbody` component. Refer to [`TossAction.cs`](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/Action/ConcreteActions/TossAction.cs) for more implementation details. | ||
armstrongl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
An important note: Any modifications to a `Rigidbody` that involve Physics (that is, modifying velocity, applying forces, applying torque, and the like.) must be done **after** the `NetworkObject` is spawned since `NetworkRigidbody` forces the Rigidbody’s `isKinematic` flag to be true on `Awake()`. Once spawned, this flag is modified depending on the ownership status of the `NetworkObject`. | ||
armstrongl marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
id: spawn-networkobjects | ||
title: Dynamically spawning NetworkObjects in Boss Room to Resolve Zombie NetworkObjects | ||
description: Learn how to dynamically spawn NetworkObjects in Boss Room to resolve zombie NetworkObjects. | ||
--- | ||
:::note | ||
Required reading: [Object Spawning](../../basics/object-spawning.md). | ||
::: | ||
|
||
This document serves as a walkthrough of Boss Room’s approach to solving the following issue: Late-joining clients entering networked sessions encountering zombie `NetworkObjects`. Zombie `NetworkObjects` represent `NetworkObjects` that are instantiated for a client due to scene loads but are not despawned or destroyed by Netcode. | ||
|
||
This is a particular Netcode limitation of `NetworkObject` spawning: `NetworkObjects` that belong to a scene object should not be destroyed until its scene has been unloaded through Netcode’s scene management. | ||
|
||
The scenario in question: | ||
|
||
* A host loads a scene and destroys a `NetworkObject` that belonged to that scene. | ||
* A client joins the host’s session and loads the additive scene. This operation loads **all** the `GameObjects` included in the additive scene. The `NetworkObject` that was destroyed on the server will not be destroyed on the client’s machine. | ||
|
||
This scenario manifested inside Boss Room, whereby late-joining clients joining a game session encountered zombie `NetworkObject`s that were not destroyed over the network. | ||
|
||
Additive scenes now contain prefab instances of a custom spawner, [`NetworkObjectSpawner`](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Packages/com.unity.multiplayer.samples.coop/Utilities/Net/NetworkObjectSpawner.cs) to accommodate this visual inconsistency. | ||
|
||
Compositionally, these additive scenes now only contain the following: | ||
|
||
* Prefab instances of level geometry. | ||
* Prefab instances of `NetworkObject`s that will **not** be despawned nor destroyed for the scene’s lifetime. Examples include [BreakablePot](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Prefabs/Game/BreakablePot.prefab) and [BreakableCrystal](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Prefabs/Game/BreakableCrystal.prefab). | ||
* Prefab instances of `NetworkObjectSpawner`, which spawn `NetworkObject`s that **may** be destroyed or despawned during the scene’s lifetime. Examples include [Imp](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/GameData/Character/Imp/Imp.asset), [VandalImp](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/GameData/Character/VandalImp/VandalImp.asset), and [ImpBoss](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/GameData/Character/ImpBoss/ImpBoss.asset). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.