-
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
fix: NetworkTransform initial synchronization, parenting, smooth transitions between transform spaces, and UI updates #3013
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
NetworkTransform
fixes pertaining to parenting, the initial synchronizing parentedNetworkObject
s 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 parentedNetworkTransform
instances.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.SwitchTransformSpaceWhenParented
When 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
NetworkTransform
components. This also automatically updates owner authoritative'sNetworkTransform.InLocalSpace
setting, handles updating/converting eachLinearBufferInterpolator
entries to the proper transform space relative to the current, previous, or current and previous (if doing aNetworkObject
toNetworkObject
transition) parent(s).This does not apply to
NetworkTransform
component(s) paired withNetworkRigidbody
component(s), as that will be the next PR update for v2.0.0.NetworkTransform.TickSyncChildren
When enabled, nested
NetworkTransform
components will be synchronized with the rootNetworkTransform
or in the event they are all nested under a rootGameObject
withNetworkObject
component the firstNetworkTransform
in 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 childNetworkTransform
components could get into a state where they are all sending updates on different ticks which can lead to visual "jittering" between the associatedGameObject
transforms.This property is automatically enabled when
NetworkTransform.SwitchTransformSpaceWhenParented
is enabled.NetworkObject.AllowOwnerToParent
This 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
NetworkObject
in order to assure there is no latency between the parenting event andNetworkTransform
updates. This is especially important when handlingNetworkObject
toNetworkObject
parenting 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.SyncOwnerTransformWhenParented
When disabled, this property will not apply the server-side transform values received via the
ParentSyncMessage
on the client owner side. This is more specific to owner authoritative motion models (i.e.NetworkTransform
with 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
ParentSyncMessage
from the server (but has no impact when using a distributed authority network topology).UI Updates &
NetcodeEditorBase
This PR also includes a new
NetcodeEditorBase
editor that can be used with anyMonoBehaviour
derived component and helps to organize inspector view properties by child class generation. TheNetworkTransform
,NetworkRigidbodyBase
, andNetworkManager
editors now derive fromNetcodeEditorBase
so 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
, andNetworkManager
custom editors, provides a clean separation between the base class and any derived child.NetworkTransform
Example:The
NetworkTransform
derived both child generation properties are collapsed:Expanding the last generation child,
MoverScriptNoRigidbody
, properties:Expanding the
NetworkTransform
parent class properties:NetworkManager
Example:For those who like to store additional netcode and/or project specific settings in the same place, deriving from the
NetworkManager
while usingNetcodeEditorBase
for theExtendedNetworkManagerEditor
:Collapsed:
Fully expanded:
Multi-Object Compatible
The
NetcodeEditorBase
is Multi-Object compatible. Below is a prefab with several children selected that have the samePlayerBallMotion : NetworkTransform
component:When the
NetworkTransform
properties 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.SwitchTransformSpaceWhenParented
property that, when enabled, will handle the world to local, local to world, and local to local transform space transitions when interpolation is enabled.NetworkTransform.TickSyncChildren
that, when enabled, will tick synchronize nested and/or childNetworkTransform
components to eliminate any potential visual jittering that could occur if theNetworkTransform
instances get into a state where their state updates are landing on different network ticks.NetworkObject.AllowOwnerToParent
property to provide the ability to allow clients to parent owned objects when running in a client-server network topology.NetworkObject.SyncOwnerTransformWhenParented
property 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.NetcodeEditorBase
editor helper class to provide easier modification and extension of the SDK's components.NetworkTransform
synchronization of parentedNetworkObject
instances.NetworkTransform.SwitchTransformSpaceWhenParented
to be enabled).NetworkTransformEditor
so it now derives fromNetcodeEditorBase
.NetworkRigidbodyBaseEditor
so it now derives fromNetcodeEditorBase
.NetworkManagerEditor
so it now derives fromNetcodeEditorBase
.Testing and Documentation