Skip to content

Conversation

NoelStephensUnity
Copy link
Collaborator

@NoelStephensUnity NoelStephensUnity commented Sep 9, 2025

Purpose of this PR

This PR resolves the issue where setting SwitchTransformSpaceWhenParented to true and then setting InLocalSpace to true will force the motion authority to continually send updates each tick (whether there is a delta or not).

Jira ticket

MTTB-1584

fix: #3653
fix: #3646
fix: #3645

Changelog

  • Added: NetworkRigidbody documentation section.
  • Fixed: NetworkTransform state synchronization issue when NetworkTransform.SwitchTransformSpaceWhenParented is enabled and the associated NetworkObject is parented multiple times in a single frame or within a couple of frames.
  • Fixed: Issue when spawning, parenting, and immediately re-parenting.
  • Changed: NetworkTransform now synchronizes NetworkTransform.SwitchTransformSpaceWhenParented when it is updated by the motion model authority.
  • Changed: NetworkObjects pending to be shown to clients can now occur on partial network ticks. If any pending NetworkObjects pending to be shown to clients happens to be ready on a new network tick they still are shown after network variable deltas have been processed.
  • Changed: The default NetworkDelivery used by all messages is now reliable fragmented sequenced with the exception of named, unnamed, and any messages sent with a user specified network delivery type. This assures certain order of operations to be preserved when same call-stack changes are applied to a newly spawned, authority side, NetworkObject.
  • Changed: NetworkTransform documentation to better reflect the Teleport methods intended usage along with updates to NetworkObject and physics areas of the documentation.

Documentation (WIP)

  • Includes documentation for existing public API entry points:
    • Updates to the SwitchTransformSpaceWhenParented XML API that provides additional information about usage.
    • Updates to the SetState and Teleport for more clarity on intended usage for both network topologies.
    • Updates to NetworkObject.SpawnWithOwnership to call out how spawning with ownership can impact things like NetworkTransform during the spawning sequence when using a client-server topology.
  • Includes updates to existing documentation:
    • Updates to NetworkTransform regarding the use of SwitchTransformSpaceWhenParented.
      • Add section covering spawning, order of operations, and how timing and network topology can impact the end result.
        • Include SetState/Teleport, spawning (with or without) ownership, and the authority motion model.
    • Updates to the NetworkObject spawning section
      • Expand the coverage to include:
        • Spawning then changing ownership vs SpawnWithOwnership
        • Spawning, NetworkTransform, and parenting.
    • Updated physics
      • Includes parenting physics objects using attachables.
    • Added a first pass (still could use some additions in the future) NetworkRigidbody section (pulled this part out of physics).

WIP Documentation

Testing & QA (How your changes can be verified during release Playtest)

Functional Testing

Manual testing :

  • [ X ] Manual testing done
    • The original CharacterControllerMovingBodies project.
      • This verifies the existing functionality was not broken.
    • The manual test mentioned above that was used to replicate the user's issues and fix them.
      • This verifies (n) parenting events can occur on a single frame and it will be sychronized.

Automated tests:

  • Covered by existing automated tests
  • [ X ] Covered by new automated tests
    • (wip)

Does the change require QA team to:

  • Review automated tests?
  • Execute manual tests?
  • Provide feedback about the PR?

If any boxes above are checked the QA team will be automatically added as a PR reviewer.

Backports

This is an NGO v2.x.x specific issue. No backport is required.

Assure that the local InLocalSpace field is updated to match the parented status.
Reset IsTeleporting and ExplicitSet after invoking OnAuthorityPushTransformState so these values are preserved for user script.

Automatically adjust InLocalSpace when spawning a NeworkObject based on the NetworkObject's current parented status when SwitchTransformSpaceWhenParented is enabled.
Invoking the OnAuthorityPushTransformState and OnNetworkTransformStateUpdated when synchronizing in order to provide users with the NetworkTransformState used to synchronize a NetworkTransform when first spawned.
Revert moving where IsTeleportingNextFrame and ExplicitSet are reset.
Add WasTeleported to NetworkTransformState in order to preserve whether the pushed state was teleported or not.
Adding documentation updates.
XML API update
Copy link
Contributor

@jabbacakes jabbacakes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left suggestions on the smaller changes - have pushed a commit with changes to the larger new additions to the NetworkTransform page, mostly just trying to improve clarity and reduce verbiage.

This page is getting very long, might break it up at some point, but will do that in a separate PR.

NoelStephensUnity and others added 8 commits September 12, 2025 13:55
NetworkSpawnManager:
Relative to spawning only, process deferred messages after post spawn.

NetworkTransform:
Synchronize the SwitchTransformSpaceWhenParented flag when it changes on the authority side.
Perform an early check in CheckForStateChange for changes to SwitchTransformSpaceWhenParented.
Apply changes to SwitchTransformSpaceWhenParented when processing a state update on non-authority instance.
Co-authored-by: Amy Reeve <amy.reeve@unity3d.com>
…orm.cs

Co-authored-by: Amy Reeve <amy.reeve@unity3d.com>
…orm.cs

Co-authored-by: Amy Reeve <amy.reeve@unity3d.com>
…orm.cs

Co-authored-by: Amy Reeve <amy.reeve@unity3d.com>
A complete refactoring of how parenting is handled when NetworkTransform.SwitchTransformSpaceWhenParented is enabled to provide a complete 1:1 match of (n) back-to-back parenting actions and/or many parenting actions that occur over several frames. This preserves the order of operations, sends 1 full state update plus an added parenting directive per action immediately, and then upon receiving the non-authority instances will apply the parenting, transform the local values and interpolators' queued entries  between transform spaces (world to local, local to world, or local to local).
@NoelStephensUnity
Copy link
Collaborator Author

/ci ngo

Standards/style fix.
@NoelStephensUnity
Copy link
Collaborator Author

/ci ngo

More hidden white spaces...
@NoelStephensUnity
Copy link
Collaborator Author

/ci ngo

Removing one line space
@NoelStephensUnity
Copy link
Collaborator Author

/ci ngo

@NoelStephensUnity NoelStephensUnity marked this pull request as ready for review September 15, 2025 13:31
@NoelStephensUnity NoelStephensUnity requested a review from a team as a code owner September 15, 2025 13:31
Reverting last change.
Removing a single line of code.
@NoelStephensUnity NoelStephensUnity requested review from EmandM and a team as code owners September 15, 2025 15:16
NoelStephensUnity and others added 7 commits September 15, 2025 11:37
Migrating all NetworkTransform serialization into the NetworkTransformMessage.
Removing legacy observers for the NetworkTransform.
Increment count after check when iterating through observers.
remove whitespaces.
Add a test to validate this PR.
Co-authored-by: Amy Reeve <amy.reeve@unity3d.com>
Adjusting based on the PR's recent updates.
Refactoring the physics section.
Moved the NetworkRigidbody content out of physics and into a new NetworkRigidbody section under componetns.
Moved physics up to the components layer.
Did a large update to the physics documentation and provided an additional walk through of  how to "parent" physics bodies using attachables.
Adding one suggested change I left out.
Fixing trailing spaces.
Further clarifying the update to NetworkObject.SpawnWithOwnership
If half float precision is enabled, then update the current half float position state after transforming the current position due to a change in the NetworkObject's status.
Updating the SwitchTransformSpaceWhenParented test to validate using various NetworkTransform configurations (i.e. half precision, quaternion, quaternion compressed) while also parenting with world position stays enabled and disabled.

Removing trailing space in recent documentation update.
adding additional changelog entries.
reflecting the current version of this file from main branch.
Try this one more time.
@@ -1,4 +1,4 @@
"""Helper class for common operations."""
"""Helper class for common operations."""
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an artifact from earlier changes... just reflecting what it is currently in the main v2 branch.

NoelStephensUnity and others added 3 commits September 17, 2025 14:02
Making NetworkTransformState.SwitchTransformSpaceWhenParented internal as it doesn't really need to be public for its use case.
Copy link
Contributor

@jabbacakes jabbacakes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alrighty, that was quite a lot 😅 I've just been through and given it a bit of polish. Main change to note is that I've modified the walkthrough of AttachableBehaviour parenting to be a bit more docsy (fewer asides and less conversational tone).

jabbacakes and others added 6 commits September 19, 2025 14:48
Relatively large change:

- Preserving order of operations by making the default network delivery be reliable fragmented sequenced with the exception of named, unnamed, and any message types adjusted explicitly by user code to use a different network delivery method.

- Adjusted parenting directive to allow the server to force a parenting directive on a NetworkTransform it does not have the motion authority over.

- The NetworkObjects to show now will be also processed in-between ticks to preserve order of operations.
  - NetworkObjects pending to be shown on the same frame as the tick update will still be processed during the tick update.
Left out the half precision adjustment in the server-side edge case for back-to-back changes.
Adding additional change log entries.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants