-
Notifications
You must be signed in to change notification settings - Fork 450
feat: AttachableBehaviour and ComponentController #3518
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
Draft
NoelStephensUnity
wants to merge
17
commits into
develop-2.0.0
Choose a base branch
from
feat/attachable-networkbehaviour-and-object-controller
base: develop-2.0.0
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.
Draft
feat: AttachableBehaviour and ComponentController #3518
NoelStephensUnity
wants to merge
17
commits into
develop-2.0.0
from
feat/attachable-networkbehaviour-and-object-controller
Conversation
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
…d-object-controller
…d-object-controller
Minor XML API fixes.
Simplified the nameof AttachableBehaviour.Detach to just Detach.
…d-object-controller
Refactoring the ComponentController to provide more flexibility as well as being able to have component entries that will apply the inverse of the current ComponentController's current state....which allows for switching between different sets of components depending upon the controller's state.
switching to a Light component as opposed to BoxCollider as BoxCollider requires the physics package and we are just testing the functionality of ComponentController and not specifically any one other type of component.
…d-object-controller
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.
AttachableNetworkBehaviour and Support Components
The purpose of this PR (feat) is to address the complexity of "picking up" or "dropping" an item in the world which can become complex when using the traditional
NetworkObject
parenting pattern. In this PR there are three primary components added to help reduce this complexity:AttachableBehaviour
: Provides "out of the box" support for attaching (i.e. parenting) a nested childGameObject
that includes anAttachableBehaviour
component to another nested childGameObject
with anAttachableNode
component that is associated with a differentNetworkObject
.AttachableNode
: This component is required by theAttachableBehaviour
component in order to be able to attach (i.e. parent) to another GameObject without having to parent the entireNetworkObject
component theAttachableBehaviour
component is associated with.ComponentController
: This component provides users the ability to synchronize the enabling or disabling of anyObject
derived component that has anenabled
property.This PR also incorporates a new "Helpers" subfolder under the NGO components folder where additional helper components will live.
Attaching vs NetworkObject parenting
Fundamentally, attaching is another form of synchronized (i.e. netcode) parenting that does not require one to use the traditional
NetworkObject
parenting. Attaching a childGameObject
nested under aNeworkObject
(really theGameObject
theNetworkObject
component belongs to) will only take the childGameObject
and parent it under another childGameObject
nested under or on the sameGameObject
with a differentNeworkObject
.NetworkObject parenting
The traditional approach has been to spawn two network prefab instances:

Then parent one instance under the other:

This is simple enough for many scenarios, but can become cumbersome under more specific scenarios where a user might want to have a "world" version of the item and a "picked up" version of the item.
Attaching
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).NetworkObject
component is placed.By placing an

AttachableBehaviour
component on the NestedChild-PickedUpGameObject
and anAttachableNode
component on the TargetNode, a user can then invoke theAttachableBehaviour.Attach
method while passing in theAttachableNode
component and the NestedChild-PickedUpGameObject
will get parented under the TargetNode while also synchronizing this action with all other clients.ComponentController
Taking the above example into consideration, it would make sense that a user would want to be able to easily control whether a specific component is enabled or disabled. As an example:
MeshRenderer
,Collider
, and other components on the NestedChild-PickedUpGameObject
while enabling similar types of components on the NestedChild-World.MeshRenderer
,Collider
, and other components on the NestedChild-PickedUpGameObject
while disabling similar types of components on the NestedChild-World.The
ComponentController
provides this type of functionality.Changelog
Testing and Documentation
Backport
These new helper components are currently only targeting v2.x.