fix: NetworkTransform initial synchronization, parenting, and smooth transitions between transform spaces
This PR contains a handful of NetworkTransform fixes pertaining to parenting, the initial synchronization of newly joined clients when NetworkObjecs are parenting, as well as the issue with not being able to have world to local space and local to world space smooth transitions while interpolation is enabled.
To now properly parent and have NetworkObjects move in local space relative to their parent (in order to have jitter free synchronization of a parent that is also a moving body) one only needs to:
- Parent the child
- Upon the
NetworkBehaviour.OnNetworkObjectParentChangedmethod being invoked, set the child's transform space to local space if parented and world space if not.
Example:
public override void OnNetworkObjectParentChanged(NetworkObject parentNetworkObject)
{
if (CanCommitToTransform)
{
InLocalSpace = parentNetworkObject != null;
}
base.OnNetworkObjectParentChanged(parentNetworkObject);
}
(A full example project of how to use this will be pushed under the Examples folder following this PR being merged.)
This PR also addresses the scenario where you might not want a server's parenting message to apply the server's transform values when using an owner authoritative motion model. Now you can disable owner transform synchronization by disabling the Sync Owner Transform When Parented property:
fix: #2959 fix: #2913 fix: #2856 fix: #2843 fix: #2842
Changelog
- Added
Sync Owner Transform When Parentedproperty 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. - Fixed issue with newly joined
NetworkTransformsynchronization whenNetworkObjectis parented. - Fixed issue with smooth transitions between transform spaces when interpolation is enabled.
Testing and Documentation
- Includes integration tests (wip).
- No documentation changes or additions were necessary.