-
Notifications
You must be signed in to change notification settings - Fork 435
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
feat: Adds nested NetworkObject support in prefabs #2645
Open
Clicky02
wants to merge
10
commits into
Unity-Technologies:develop
Choose a base branch
from
Clicky02:nested_game_objects
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: Adds nested NetworkObject support in prefabs #2645
Clicky02
wants to merge
10
commits into
Unity-Technologies:develop
from
Clicky02:nested_game_objects
Conversation
This file contains 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
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
PR has been updated to fix a number of issues and to add tests |
Any update on this? The PR is not merged |
Still waiting after almost a year :( |
I need this too. This is the only feature that is making it impossible for me to use Netcode for GameObjects properly. Please make this happen! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Allows users to spawn nested NetworkObjects in prefabs. This is done using a new dependent NetworkObjects system.
When you spawn a prefab with nested NetworkObjects, all of the nested NetworkObjects will also be spawned/synchronized. These nested NetworkObjects will be dependent on the root NetworkObject. This means they are initially synchronized in the same message as the root NetworkObject, and cannot outlive the root NetworkObject (when the root gets destroyed the depending NetworkObjects will be destroyed as well). Aside from these two exceptions, depending NetworkObjects behave identically to normal NetworkObjects.
To achieve this I made 3 major changes:
NetworkObject
for saving its dependent NetworkObject and depending NetworkObjects. Respectively, these arem_DependentNetworkObject
andm_DependingNetworkObjects
. They are determined inOnValidate
and have public getters.Spawn()
is called on a NetworkObject, it locally spawns depending NetworkObjects as well.SceneObject
struct (which contains the data needed to spawn or initially synchronize NetworkObjects) now contains a list ofDependingSceneObject
s. This is a new struct that contains a subset of the properties ofSceneObject
along with aIsSpawned
boolean. When a SceneObject is spawned remotely, the information in theDependingSceneObject
list is used to initialize the depending NetworkObjects. AnyDependingSceneObject
whereIsSpawned
is false has its corresponding NetworkObject destroyed instead of initialized. This occurs when a depending NetworkObject has been destroyed before the NetworkObject it is dependent on.Resolves #2637
Changelog
Testing and Documentation