-
Notifications
You must be signed in to change notification settings - Fork 463
fix: NetworkTransform initial synchronization, parenting, smooth transitions between transform spaces, and UI updates #3013
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
Conversation
This fixes a synchronization issue with owner authoritative instances when running in client-server mode and parenting. When the server sends a parent sync message back with the position of the client's owned object it is out of sync with the client's position by the time the message is received. This fix gives users the option to not synchronize the transform position of a NetworkObject when using an owner authoritative motion mode.
This fix provides users with the option to have child `NetworkTransform`(s) tick synchronized with their parent. When the parent has `TickSyncChildren` enabled, any child `NetworkTransform`(s) that the local client has authority over will force a synchronization of their transform state. When a client is not the authority of the parent but it is the authority of one or more children, then when the parent sends a state update it will force the child/children the client has authority over to send a state update. Children will still send state updates if the transform has a delta that exceeds an axis threshold and the parent has yet to send a synchronization, but if a parent sends a synchronization within the same tick period the child/children will still send another state update.
…er-object-parenting-no-sync-transform-option
Renaming some internal properties that are common names and would conflict with serialization if a user defined them in a derived class. Making sure both the position and rotation interpolators are configured for the transform space when reset. Adding the ability to change the parent locally when running with a client-server network topology. Adding SwitchTransformSpaceWhenParented property to the NetworkTransformEditor. Shifting all of the non-authority's final synchronization logic to occur either once a client's initial connection synchronization is complete or when all of the NetworkObject's components have run through the spawn process.
Adding some improved and needed UI updates to NetworkBehaviour derived components and NetworkManager. This includes a new NetcodeEditorBase class that allows users to more easily create customized, multi-generation, components that have their properties organized based on the generation of each child.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a little comment here. I like the foldout idea, but I think maybe we can take the call-to-action buttons out so users can access them without expanding the foldout content, especially during runtime when there's nothing much within the foldout section. I made a quick mock here! Please lemme know if this makes sense!
Side note: would it make sense to show network manager properties during runtime? will people need this information?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome feedback... and good points.
Made the suggested changes and pushed the update.
👍
…th parenting transform space transitions (#3039) * chore Adding example of using a CharacterController that has no Rigidbody and being able to parent it under a moving and/or rotating body. This uses to be finalized NetworkTransform updates for NGO v2.x.x. * chore adding the manifest file * chore removing packages file * update Adding gitignore * fix Adding an elevator moving body. Fixing issue with disabling the GameObject vs disabling the CharacterController. * update Updating the example to mirror the most recent updates to #3013 * Create Readme.md place holder read me * Update Readme.md WIP updates added some additional sections and screenshots * update Adding [CanEditMultipleObjects] to RotatingBodyLogicEditor. Minor scene updates. * Update Readme.md * Update Readme.md * update cleaning up a bit. combining connect disconnect notifications into the extended networkmanager. made the single z-axis motion a path as opposed to the hacky way I did it originally. * update Adding some bumpers for extended networkmanager and selecting a connection type vs the selected network topology and vice versa. * Update Readme.md * update pointing to the develop-2.0.0 branch

Parenting & Smooth Transform Space Transitions
This PR contains a handful of
NetworkTransformfixes pertaining to parenting, the initial synchronizing parentedNetworkObjects with newly/late joined clients, issues with smooth transform space transitions (specific to parenting) while interpolation is enabled, and provides the ability to tick synchronize nested and parentedNetworkTransforminstances.Side Note: #3039 is the example project to that demonstrates these updates and includes additional (and useful) helper classes.
The below described properties allow for seamless transform space parenting and transitions when interpolation is enabled (primarily focusing on the owner authoritative motion model), and only requires setting the parent of the owned
NetworkObject(i.e. no more predicting RTT between the server and client owner) to accomplish this.Side Note: This is only for non-Rigidbody spawned instances. There will be a follow up PR to handle the Rigidbody approach that will still leverage from some of the below properties, but there is a different dynamic involved with PhysX based "parenting" (i_n reality there is no such thing as local space in the PhysX simulation so using Joints combined with tick synchronized children is the better approach_).
NetworkTransform.SwitchTransformSpaceWhenParentedWhen enabled, the "Tick Sync Children" property is automatically enabled to assure any already parented children will be synchronized properly as well as it handles tick synchronizing nested
NetworkTransformcomponents. This also automatically updates owner authoritative'sNetworkTransform.InLocalSpacesetting, handles updating/converting eachLinearBufferInterpolatorentries to the proper transform space relative to the current, previous, or current and previous (if doing aNetworkObjecttoNetworkObjecttransition) parent(s).This does not apply to
NetworkTransformcomponent(s) paired withNetworkRigidbodycomponent(s), as that will be the next PR update for v2.0.0.NetworkTransform.TickSyncChildrenWhen enabled, nested
NetworkTransformcomponents will be synchronized with the rootNetworkTransformor in the event they are all nested under a rootGameObjectwithNetworkObjectcomponent the firstNetworkTransformin that hierarchy.How this works:
When the root
NetworkTransform(on the authoritative instance) detects a state update needs to be sent, it will then have all nested and/or child (parented)NetworkTransforms(as long as the client has authority over them) send state updates. This helps to prevent a potential issue where nested or childNetworkTransformcomponents could get into a state where they are all sending updates on different ticks which can lead to visual "jittering" between the associatedGameObjecttransforms.This property is automatically enabled when
NetworkTransform.SwitchTransformSpaceWhenParentedis enabled.NetworkObject.AllowOwnerToParentThis is primarily a property for client-server network topology based projects that might use an owner authoritative motion model (typically for player avatars/prefabs). Enabling this property allows the client owner to immediately parent the owned object under another
NetworkObjectin order to assure there is no latency between the parenting event andNetworkTransformupdates. This is especially important when handlingNetworkObjecttoNetworkObjectparenting when using a client-server network topology in order to maintain smooth transitions on non-authoritative instances.Note: Setting this property when using a distributed authority network topology has no effect since client owners already have the authority to handle immediate local parenting.
NetworkObject.SyncOwnerTransformWhenParentedWhen disabled, this property will not apply the server-side transform values received via the
ParentSyncMessageon the client owner side. This is more specific to owner authoritative motion models (i.e.NetworkTransformwith owner authority) but can be useful under other scenarios where having the client owner not applying the server-side's transform state is required. Disabling this property impacts non-authoritative instances in the following ways (depending upon the network topology being used):When enabled (default), client owner will apply the server's transform state when receiving the
ParentSyncMessagefrom the server (but has no impact when using a distributed authority network topology).UI Updates &
NetcodeEditorBaseThis PR also includes a new
NetcodeEditorBaseeditor that can be used with anyMonoBehaviourderived component and helps to organize inspector view properties by child class generation. TheNetworkTransform,NetworkRigidbodyBase, andNetworkManagereditors now derive fromNetcodeEditorBaseso any child derived from one of these three components will provide this separation of child generation relative properties. When used in their original form (i.e. not a component derived from) it will show only the properties and not apply the foldout group.Folder Grouping of Each Generational Child
The
NetcodeEditorBase, used byNetworkTransform,NetworkRigidbodyBase, andNetworkManagercustom editors, provides a clean separation between the base class and any derived child.NetworkTransformExample:The



NetworkTransformderived both child generation properties are collapsed:Expanding the last generation child,
MoverScriptNoRigidbody, properties:Expanding the
NetworkTransformparent class properties:NetworkManagerExample:For those who like to store additional netcode and/or project specific settings in the same place, deriving from the


NetworkManagerwhile usingNetcodeEditorBasefor theExtendedNetworkManagerEditor:Collapsed:
Fully expanded:
Multi-Object Compatible
The


NetcodeEditorBaseis Multi-Object compatible. Below is a prefab with several children selected that have the samePlayerBallMotion : NetworkTransformcomponent:When the
NetworkTransformproperties are expanded, you get the same custom editor view for all selected objects:MTTB-66
MTTB-6
fix: #2959
fix: #2913
fix: #2856
fix: #2843
fix: #2842
Changelog
NetworkTransform.SwitchTransformSpaceWhenParentedproperty that, when enabled, will handle the world to local, local to world, and local to local transform space transitions when interpolation is enabled.NetworkTransform.TickSyncChildrenthat, when enabled, will tick synchronize nested and/or childNetworkTransformcomponents to eliminate any potential visual jittering that could occur if theNetworkTransforminstances get into a state where their state updates are landing on different network ticks.NetworkObject.AllowOwnerToParentproperty to provide the ability to allow clients to parent owned objects when running in a client-server network topology.NetworkObject.SyncOwnerTransformWhenParentedproperty to provide a way to disable applying the server's transform information in the parenting message on the client owner instance which can be useful for owner authoritative motion models.NetcodeEditorBaseeditor helper class to provide easier modification and extension of the SDK's components.NetworkTransformsynchronization of parentedNetworkObjectinstances.NetworkTransform.SwitchTransformSpaceWhenParentedto be enabled).NetworkTransformEditorso it now derives fromNetcodeEditorBase.NetworkRigidbodyBaseEditorso it now derives fromNetcodeEditorBase.NetworkManagerEditorso it now derives fromNetcodeEditorBase.Testing and Documentation