-
Notifications
You must be signed in to change notification settings - Fork 462
fix: networktransform SwitchTransformSpaceWhenParented forces updates when InLocalSpace is true #3664
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
Merged
NoelStephensUnity
merged 132 commits into
develop-2.0.0
from
fix/networktransform-autoswitchspace-forcing-updates-localspace
Oct 18, 2025
Merged
fix: networktransform SwitchTransformSpaceWhenParented forces updates when InLocalSpace is true #3664
Changes from 112 commits
Commits
Show all changes
132 commits
Select commit
Hold shift + click to select a range
5a83370
fix
NoelStephensUnity 952a40b
fix
NoelStephensUnity 983bd1b
update
NoelStephensUnity 1d36492
Merge branch 'develop-2.0.0' into fix/networktransform-autoswitchspac…
NoelStephensUnity 9adf1e5
update
NoelStephensUnity 6440658
Merge branch 'fix/networktransform-autoswitchspace-forcing-updates-lo…
NoelStephensUnity 46d1854
update
NoelStephensUnity 197f4b0
update
NoelStephensUnity 7ab9dc1
Doc pass on NetworkTransform additions
jabbacakes d3347bd
fix
NoelStephensUnity b26de65
Merge branch 'fix/networktransform-autoswitchspace-forcing-updates-lo…
NoelStephensUnity db33128
Update com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs
NoelStephensUnity ba36860
Update com.unity.netcode.gameobjects/Runtime/Components/NetworkTransf…
NoelStephensUnity ddc7c36
Update com.unity.netcode.gameobjects/Runtime/Components/NetworkTransf…
NoelStephensUnity c489e6f
Update com.unity.netcode.gameobjects/Runtime/Components/NetworkTransf…
NoelStephensUnity ae61807
Merge branch 'develop-2.0.0' into fix/networktransform-autoswitchspac…
NoelStephensUnity 2521520
refactor
NoelStephensUnity 649b989
style
NoelStephensUnity a267896
style - PVP
NoelStephensUnity 4605249
update
NoelStephensUnity 4917d40
Merge branch 'develop-2.0.0' into fix/networktransform-autoswitchspac…
NoelStephensUnity 1dc4e4f
update
NoelStephensUnity 07731e5
update
NoelStephensUnity e444a1b
update
NoelStephensUnity 25bfb07
update
NoelStephensUnity 06f2ead
upate
NoelStephensUnity 41f8c36
style
NoelStephensUnity ef5090f
test
NoelStephensUnity 7d05df9
Apply suggestions from code review
NoelStephensUnity fb99ba2
doc: update
NoelStephensUnity 0908d74
doc: style
NoelStephensUnity aef1185
style - PVP
NoelStephensUnity 473fcd8
update
NoelStephensUnity 885452a
fix
NoelStephensUnity e24aff1
test and style
NoelStephensUnity b0e4510
Merge branch 'develop-2.0.0' into fix/networktransform-autoswitchspac…
NoelStephensUnity 0a35b95
update
NoelStephensUnity bc20e16
update
NoelStephensUnity 5f34872
update
NoelStephensUnity cf27a00
update
NoelStephensUnity 8af2c0e
Docs pass on new content
jabbacakes 909be07
Reinstating note
jabbacakes a65d89e
Updating landing page
jabbacakes 4df63ea
refactor
NoelStephensUnity 99a33cf
Merge branch 'fix/networktransform-autoswitchspace-forcing-updates-lo…
NoelStephensUnity a4e8570
update
NoelStephensUnity 400172f
Merge branch 'develop-2.0.0' into fix/networktransform-autoswitchspac…
NoelStephensUnity f8a8125
update
NoelStephensUnity 1f435e0
update
NoelStephensUnity 79b602a
fix
NoelStephensUnity dea7aae
fix
NoelStephensUnity d71ebca
fix
NoelStephensUnity 6f87b1d
refactor
NoelStephensUnity 44df5f4
style - PVP
NoelStephensUnity fdfa924
refactor
NoelStephensUnity 6b3ca04
fix
NoelStephensUnity ed2300f
fix
NoelStephensUnity 1b1417b
fix
NoelStephensUnity f8ea16b
Merge branch 'develop-2.0.0' into fix/networktransform-autoswitchspac…
NoelStephensUnity 6b426bd
refactor and fix
NoelStephensUnity 4721384
fix
NoelStephensUnity 810d71b
fix
NoelStephensUnity dbb1700
Merge branch 'develop-2.0.0' into fix/networktransform-autoswitchspac…
NoelStephensUnity 8fc12aa
update
NoelStephensUnity 720e64e
fix
NoelStephensUnity f004cc6
fix
NoelStephensUnity 6673c82
fix
NoelStephensUnity b73615c
fix
NoelStephensUnity 22f87dd
test
NoelStephensUnity 7ccaa51
style
NoelStephensUnity 22728b7
test - fix
NoelStephensUnity 5d1918c
fix and update
NoelStephensUnity 04ab564
test
NoelStephensUnity 6653712
style
NoelStephensUnity 77cf501
style - PVP
NoelStephensUnity d118767
refactor
NoelStephensUnity 11f49ff
fix
NoelStephensUnity cbe3d71
update
NoelStephensUnity 1ba970a
style
NoelStephensUnity 2e1c329
refactor
NoelStephensUnity 43d7379
Merge branch 'develop-2.0.0' into fix/networktransform-autoswitchspac…
NoelStephensUnity c9ff4d1
update
NoelStephensUnity c945ffb
update
NoelStephensUnity b9a3a10
refactor
NoelStephensUnity 5a56eef
fix
NoelStephensUnity 158821c
fix
NoelStephensUnity 37447b6
update
NoelStephensUnity 1d40cad
Merge branch 'develop-2.0.0' into fix/networktransform-autoswitchspac…
NoelStephensUnity ea92fd7
fix
NoelStephensUnity 3199d5a
Merge branch 'develop-2.0.0' into fix/networktransform-autoswitchspac…
NoelStephensUnity ad0e6b4
fix
NoelStephensUnity 4588548
Merge branch 'develop-2.0.0' into fix/networktransform-autoswitchspac…
NoelStephensUnity 2d8e1cc
fix
NoelStephensUnity 62a0f1c
fix - refactor
NoelStephensUnity fb71810
Merge branch 'develop-2.0.0' into fix/networktransform-autoswitchspac…
NoelStephensUnity f5d1b56
test - wip
NoelStephensUnity 0d59c57
test
NoelStephensUnity 8bfad34
Merge branch 'develop-2.0.0' into fix/networktransform-autoswitchspac…
NoelStephensUnity 989304f
style
NoelStephensUnity 70f7a1a
style
NoelStephensUnity 39fe8be
Test-update
NoelStephensUnity f593acc
test
NoelStephensUnity aaaea3c
update
NoelStephensUnity 773b6c0
Merge branch 'develop-2.0.0' into fix/networktransform-autoswitchspac…
NoelStephensUnity e85b487
test
NoelStephensUnity 358d3cf
test-fix
NoelStephensUnity 989d9b4
doc
NoelStephensUnity 2face09
Merge branch 'develop-2.0.0' into fix/networktransform-autoswitchspac…
NoelStephensUnity faa6201
Merge branch 'develop-2.0.0' into fix/networktransform-autoswitchspac…
NoelStephensUnity f749e67
fix
NoelStephensUnity edaed82
Merge branch 'develop-2.0.0' into fix/networktransform-autoswitchspac…
NoelStephensUnity f958400
Merge branch 'develop-2.0.0' into fix/networktransform-autoswitchspac…
NoelStephensUnity 1ad835a
Merge branch 'develop-2.0.0' into fix/networktransform-autoswitchspac…
NoelStephensUnity 891ef03
Update com.unity.netcode.gameobjects/Runtime/Components/NetworkTransf…
NoelStephensUnity 9131863
Update com.unity.netcode.gameobjects/Documentation~/components/core/n…
NoelStephensUnity 0fd705b
Apply suggestion from @EmandM
NoelStephensUnity 7a96589
Apply suggestion from @EmandM
NoelStephensUnity ae62bfb
Apply suggestion from @EmandM
NoelStephensUnity 66fe88e
Update CHANGELOG.md
NoelStephensUnity 9447ffe
update
NoelStephensUnity 45939b0
doc - fix
NoelStephensUnity 92df94a
PVP
NoelStephensUnity b4f85f2
fix
NoelStephensUnity 11b01cd
test - fix
NoelStephensUnity 5987dbc
test - refactor
NoelStephensUnity 392464f
test-fix
NoelStephensUnity e1e76dc
Apply suggestion from @EmandM
NoelStephensUnity fecfe20
fix
NoelStephensUnity e0143f7
style
NoelStephensUnity abb8544
refactor
NoelStephensUnity 97431e1
update
NoelStephensUnity f0a0ee7
Update com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviourUpd…
NoelStephensUnity File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
460 changes: 428 additions & 32 deletions
460
com.unity.netcode.gameobjects/Documentation~/advanced-topics/physics.md
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
42 changes: 42 additions & 0 deletions
42
com.unity.netcode.gameobjects/Documentation~/components/helper/networkrigidbody.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # NetworkRigidbody | ||
NoelStephensUnity marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| NetworkRigidbody is a component that sets the Rigidbody of the GameObject into kinematic mode on all non-authoritative instances. Authority is determined by the [NetworkTransform component](networktransform.md) (required) attached to the same GameObject as the NetworkRigidbody. Whether the NetworkTransform is server authoritative (default) or owner authoritative, the NetworkRigidBody authority model will mirror it. That way, the physics simulation runs on the authoritative instance, and the resulting positions synchronize on the non-authoritative instances, each with their RigidBody being kinematic, without any interference. | ||
|
|
||
| ## Configure NetworkRigidbody | ||
|
|
||
|  | ||
|
|
||
| When looking at a NetworkRigidbody in the Inspector view, there are three exposed values: | ||
|
|
||
| - __Use Rigid Body for Motion__ | ||
| - When enabled and using a [NetworkTransform](networktransform.md), the NetworkTransform uses the PhysX position and rotation to synchronize changes during the `FixedUpdate` loop update stage. | ||
| - __Auto Update Kinematic State__ | ||
| - When enabled, NetworkRigidbody automatically determines whether the current instance should be kinematic or non-kinematic. | ||
| - For custom solutions, you can opt to disable this field or derive from [NetworkRigidbodyBase](https://docs.unity3d.com/Packages/[email protected]/api/Unity.Netcode.Components.NetworkRigidbodyBase.html) and design your own custom networked Rigidbody handler. | ||
| - __Auto Set Kinematic On Despawn__ | ||
| - When enabled, this option makes the rigid body kinematic when despawned (which can be useful for [object pools](../../advanced-topics/object-pooling.md)). | ||
|
|
||
| Some collision events aren't fired when using NetworkRigidBody: | ||
|
|
||
| - On the server, all collision and trigger events (such as `OnCollisionEnter`) fire as expected and you can access (and change) values of the `Rigidbody` (such as velocity). | ||
| - On clients, Rigidbody is kinematic. Trigger events still fire but collision events won't fire when colliding with other networked Rigidbody instances if your project's physics settings is set to the default contact pairs. | ||
|  | ||
|
|
||
| - You can adjust the __Contact Pairs Mode__ to use kinematic and non-kinematic by setting it to __Enable All Contact Pairs__. | ||
|
|
||
| > [!NOTE] | ||
| > If there's a need for a gameplay event to happen on a collision, you can listen to the `OnCollisionEnter` function on the server and synchronize the event via `Rpc(SendTo.Everyone)` to all clients. If you plan on handling many collisions, then it's recommended to use the [RigidbodyContactEventManager component](https://docs.unity3d.com/Packages/com.unity.netcode.gameobjects@latest?subfolder=/api/Unity.Netcode.Components.RigidbodyContactEventManager.html) to handle collision checking during a job (`OnCollisionenter` can become expensive from a processing perspective if you have enough instances colliding). | ||
| ### NetworkRigidbody2D | ||
|
|
||
| NetworkRigidbody2D works in the same way as NetworkRigidbody but for 2D physics (Rigidbody2D) instead. | ||
|
|
||
| ## Rigidbody interpolation example | ||
|
|
||
| While NetworkTransform offers [interpolation](../../learn/clientside-interpolation.md) as a way to smooth between delta state updates, it doesn't get applied to the authoritative instance. You can use `Rigidbody.interpolation` for your authoritative instance while maintaining a strict server-authoritative motion model. | ||
|
|
||
| To have a client control their owned objects, you can use either [RPCs](../../advanced-topics/message-system/rpc.md) or [NetworkVariables](../../basics/networkvariable.md) on the client-side. However, this often results in the host-client's updates working as expected, but with slight jitter when a client sends updates. You might be scanning for key or device input during the `Update` to `LateUpdate` stages. Any input from the host player is applied after the `FixedUpdate` stage (such as physics simulation for the frame has already run), but input from client players is sent via a message and processed, with a half RTT delay, on the host side (or processed 1 network tick + half RTT if using NetworkVariables). Because of when messages are processed, client input updates run the risk of being processed during the `EarlyUpdate` stage which occurs just before the current frame's `FixedUpdate` stage. | ||
|
|
||
| To avoid this kind of scenario, it's recommended that you apply any changes received via messages to a Rigidbody after the `FixedUpdate` has run for the current frame. If you [refer to how NetworkTransform handles its changes to transform state](https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/blob/a2c6f7da5be5af077427eef9c1598fa741585b82/com.unity.netcode.gameobjects/Components/NetworkTransform.cs#L3028), you can see that state updates are applied during the `Update` stage, but are received during the `EarlyUpdate` stage. Following this kind of pattern when synchronizing changes to a Rigidbody via messages will help you to avoid unexpected results in your Netcode for GameObjects project. | ||
|
|
||
| The best way to address the issue of physics latency is to create a custom NetworkTransform with a custom physics-based interpolator. You can also use the [Network Simulator tool](https://docs.unity3d.com/Packages/com.unity.multiplayer.tools@latest?subfolder=/manual/network-simulator) to spot issues with latency. | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.