You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: Parenting does not preserve WorldPositionStays option and other parenting related issues (#2146)
* fix
Parenting:
Fixed the issue where WorldPositionStays was not being synchronized with clients.
Removed m_IsReparented and associated properties.
Added world position stays parameter to CreateLocalNetworkObject to preserve worldPostionStays.
This fixes some edge case scenarios and issues with parenting in-scene placed NetworkObjects.
One in particular is to provide the local space position and rotation in ParentSyncMessage if the WorldPositionStays value is false. The server might maintain the original local space values and upon being reparented it re-applies the local space values. This is only pertinent if the user decides they don't want to use a NetworkTransform for the NetworkObject in question.
Now, a users can control what the final position, rotation, and scale of a NetworkObject is when being added/removed to/from a parent's sibling list ("parented or de-parented").
Parenting and Scale:
Fixed issue where GetMessageSceneObject wasn't using the NetworkObject's lossy scale value. This would result in improper scaling of parented (WorldPositionStays = true) child NetworkObjects for late joining clients. Added comments with details on this.
Fixed edge case scenario where nested in-scene placed NetworkObject children are de-parented and then a client late joins. Under this scenario (only for in-scene placed NetworkObjects) we want the late joining client to remove its parent, then set the transform values, and then get spawned.
NetworkTransform:
Fixed issue where TryCommitTransformToServer was not honoring the NetworkTransform.InLocalSpace property.
Fixed issue where teleporting did not honor the NetworkTransforms's current synchronize axis settings.
Removed the private m_TickFrequency property as it is no longer being used.
* refactor
CreateLocalNetworkObject now just accepts the NetworkObject.SceneObject structure as opposed to the 10 properties of the NetworkObject.SceneObject structure passed in as parameters.
Provided the ability to invoke NetworkObject.TrySetParent with a null value in order to be able to remove a parent while also selecting whether they want WorldPositionStay to be true or false (when removing a parent WorldPositionStays impacts the final transform values and can lead to scale issue if you parent with WorldPositionStays set to false and then it remove the parent with WorldPositionStays set to true).
Consolidated the CreateLocalNetworkObject's assignment of the transform values, parenting, and DDOL migration.
Removed parenting from CreateLocalNetworkObject
Removed setting the cached parent directly within SpawnNetworkObjectLocallyCommon as this is done within NetworkObject.ApplyNetworkParenting.
* add
Added RemoveParent to the ParentSync message.
Added applying scale to CreateLocalNetworkObject.
Added parent child sorting to the SceneEventData's synchronization serialization process.
Added the TryRemoveParent helper method to make removing a parent easier. Without this method users will have to use TrySetParent and cast the null value to either GameObject or NetworkObject.
* test
Added ParentingWorldPositionStaysTest:
Testing with and without WorldPositionStays while also varying child position, rotation, and scale values.
Validates scale with multi-generation nested children where most of the parents have a scale other than Vector3.one.
Created abstract IntegrationTestWithApproximation to avoid replicating the exact same set of Approximately methods.
Added ParentingInSceneObjectsTests:
This includes all of the scripts and assets that the ParentingInSceneObjectsTests needs.
It includes adding the ParentingInSceneObjects scene to the scenes in build list as well.
This also verifies an in-scene placed NetworkObject parented under a GameObject will preserve that hierarchy.
NetworkTransformStateTest:
Updated the bool parameters to be more meaningful named enums so you know what exactly is being tested.
Added additional NetworkTansformState.IsTeleportingNextFrame logic to the existing test.
Added an additional "step" which verifies the NetworkTransformState is additively collapsing for each detected axial delta over the relative threshold value.
Co-authored-by: Jesse Olmer <[email protected]>
Co-authored-by: Unity Netcode CI <[email protected]>
Copy file name to clipboardExpand all lines: com.unity.netcode.gameobjects/CHANGELOG.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,8 @@ Additional documentation and release notes are available at [Multiplayer Documen
13
13
14
14
- IPv6 is now supported for direct connections when using `UnityTransport`. (#2232)
15
15
- Added WebSocket support when using UTP 2.0 with `UseWebSockets` property in the `UnityTransport` component of the `NetworkManager` allowing to pick WebSockets for communication. When building for WebGL, this selection happens automatically. (#2201)
16
+
- Added position, rotation, and scale to the `ParentSyncMessage` which provides users the ability to specify the final values on the server-side when `OnNetworkObjectParentChanged` is invoked just before the message is created (when the `Transform` values are applied to the message). (#2146)
17
+
- Added `NetworkObject.TryRemoveParent` method for convenience purposes opposed to having to cast null to either `GameObject` or `NetworkObject`. (#2146)
16
18
17
19
### Changed
18
20
@@ -33,6 +35,11 @@ Additional documentation and release notes are available at [Multiplayer Documen
33
35
- Implicit conversion of NetworkObjectReference to GameObject will now return null instead of throwing an exception if the referenced object could not be found (i.e., was already despawned) (#2158)
34
36
- Fixed warning resulting from a stray NetworkAnimator.meta file (#2153)
35
37
- Fixed Connection Approval Timeout not working client side. (#2164)
38
+
- Fixed issue where the `WorldPositionStays` parenting parameter was not being synchronized with clients. (#2146)
39
+
- Fixed issue where parented in-scene placed `NetworkObject`s would fail for late joining clients. (#2146)
40
+
- Fixed issue where scale was not being synchronized which caused issues with nested parenting and scale when `WorldPositionStays` was true. (#2146)
41
+
- Fixed issue with `NetworkTransform.ApplyTransformToNetworkStateWithInfo` where it was not honoring axis sync settings when `NetworkTransformState.IsTeleportingNextFrame` was true. (#2146)
42
+
- Fixed issue with `NetworkTransform.TryCommitTransformToServer` where it was not honoring the `InLocalSpace` setting. (#2146)
36
43
- Fixed ClientRpcs always reporting in the profiler view as going to all clients, even when limited to a subset of clients by `ClientRpcParams`. (#2144)
37
44
- Fixed RPC codegen failing to choose the correct extension methods for `FastBufferReader` and `FastBufferWriter` when the parameters were a generic type (i.e., List<int>) and extensions for multiple instantiations of that type have been defined (i.e., List<int> and List<string>) (#2142)
38
45
- Fixed the issue where running a server (i.e. not host) the second player would not receive updates (unless a third player joined). (#2127)
0 commit comments