-
Notifications
You must be signed in to change notification settings - Fork 432
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
Add Support for Nested NetworkObjects in Prefabs #2637
Labels
stat:awaiting triage
Status - Awaiting triage from the Netcode team.
type:feature
New feature, request or improvement
Comments
Clicky02
added
stat:awaiting triage
Status - Awaiting triage from the Netcode team.
type:feature
New feature, request or improvement
labels
Jul 23, 2023
Clicky02
added a commit
to Clicky02/com.unity.netcode.gameobjects
that referenced
this issue
Jul 27, 2023
Introduces the concept of Dependent NetworkObjects. Dependent NetworkObjects cannot outlive the NetworkObject they are dependent on. When spawning a prefab with nested NetworkObjects, all nested NetworkObjects are dependent on the root NetworkObject. This means that nested NetworkObjects can always be spawned/synchronized by spawning the root NetworkObject (and despawning any NetworkObjects that are no longer spawned). Resolves Unity-Technologies#2637
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
stat:awaiting triage
Status - Awaiting triage from the Netcode team.
type:feature
New feature, request or improvement
Is your feature request related to a problem? Please describe.
One major pain point of using Unity Netcode for GameObjects (as well as many other networking solutions) is the lack of support for spawning nested NetworkObjects. Currently, if you try to spawn a prefab with nested NetworkObjects, the primary NetworkObject will be networked, while all the child NetworkObjects will not.
As an example, imagine that you are trying to spawn a boat with cannons that each player can move and shoot. In this scenario, it would make sense that (1) cannons should be parented to the boat and (2) any player should be able to take ownership of a cannon (separate of the boat) when they go to move/shoot it. This means that both the boat and the cannons would need to be NetworkObjects. However, because of this limitation, you would not be able to make one boat prefab with the cannons on it.
Describe the solution you'd like
Ideally, when a prefab with nested NetworkObjects is spawned, it should automatically network any child network objects.
Describe alternatives you've considered
You can work around the issues with nested NetworkObjects, but it requires designing your prefabs/scripts in less intuitive ways.
For instance, in the boat example I mentioned earlier, you could create cannon spawners that spawn the cannons separately when the boat is spawned. However, this has its own issues. Primarily:
There are other solutions to these types of problems, but they are generally more difficult to implement and/or encourage poor design.
Additional context
N/A
The text was updated successfully, but these errors were encountered: