Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
138 commits
Select commit Hold shift + click to select a range
5571be6
update
NoelStephensUnity Dec 2, 2022
a7cde50
update
NoelStephensUnity Dec 6, 2022
343e52b
update
NoelStephensUnity Dec 6, 2022
2932d5d
update
NoelStephensUnity Dec 6, 2022
44b03cb
update
NoelStephensUnity Dec 7, 2022
6be04c5
update
NoelStephensUnity Dec 8, 2022
64855d6
update
NoelStephensUnity Dec 8, 2022
0168cc9
Merge branch 'develop' into refactor/quaternion-synchronization-netwo…
NoelStephensUnity Dec 12, 2022
a093a06
update
NoelStephensUnity Dec 13, 2022
0a03b9f
update
NoelStephensUnity Dec 13, 2022
877acc1
update
NoelStephensUnity Dec 15, 2022
73c73db
test manual
NoelStephensUnity Dec 15, 2022
e3dc079
update
NoelStephensUnity Dec 16, 2022
7183d38
update
NoelStephensUnity Dec 16, 2022
ce145ce
update
NoelStephensUnity Dec 16, 2022
220e30a
update
NoelStephensUnity Dec 16, 2022
09359bd
update
NoelStephensUnity Dec 16, 2022
d782c85
update
NoelStephensUnity Dec 16, 2022
1f10e44
fix
NoelStephensUnity Dec 16, 2022
360a267
test fix
NoelStephensUnity Dec 16, 2022
2b254f1
test updates
NoelStephensUnity Dec 16, 2022
fe68e84
update
NoelStephensUnity Dec 18, 2022
d232e7e
update
NoelStephensUnity Dec 18, 2022
419010d
update
NoelStephensUnity Dec 19, 2022
b71f7d2
tests update
NoelStephensUnity Dec 19, 2022
466bbaa
update
NoelStephensUnity Dec 20, 2022
bcc5f8f
update
NoelStephensUnity Dec 22, 2022
9ec0e4c
Test
NoelStephensUnity Dec 22, 2022
fd3dcd1
update and test
NoelStephensUnity Dec 22, 2022
a96d12b
update
NoelStephensUnity Dec 24, 2022
924644c
test manual
NoelStephensUnity Dec 24, 2022
756c77f
test
NoelStephensUnity Dec 24, 2022
89acab4
update
NoelStephensUnity Dec 24, 2022
a4822ac
update
NoelStephensUnity Dec 29, 2022
b25d582
fix
NoelStephensUnity Dec 29, 2022
7d3d313
test manual
NoelStephensUnity Dec 29, 2022
3bd4807
test
NoelStephensUnity Dec 29, 2022
dc1ab6d
test
NoelStephensUnity Dec 29, 2022
63f9169
update
NoelStephensUnity Dec 30, 2022
1e58592
test manual
NoelStephensUnity Dec 30, 2022
3435165
update
NoelStephensUnity Dec 31, 2022
a9df8a6
update
NoelStephensUnity Dec 31, 2022
b76d835
test manual
NoelStephensUnity Dec 31, 2022
cf23afd
update - wip
NoelStephensUnity Jan 1, 2023
5151180
update
NoelStephensUnity Jan 2, 2023
b894b8c
test manual
NoelStephensUnity Jan 2, 2023
0829500
test
NoelStephensUnity Jan 2, 2023
c7ea4c0
update
NoelStephensUnity Jan 2, 2023
29269ca
style and minor update
NoelStephensUnity Jan 2, 2023
03aca55
update - precision adjustment
NoelStephensUnity Jan 3, 2023
576e3be
test manual
NoelStephensUnity Jan 3, 2023
28cc889
update
NoelStephensUnity Jan 4, 2023
1809fee
tests manual
NoelStephensUnity Jan 4, 2023
b76a455
test manual
NoelStephensUnity Jan 4, 2023
89fec61
test
NoelStephensUnity Jan 4, 2023
50a664d
test
NoelStephensUnity Jan 5, 2023
b674ac3
update - remove
NoelStephensUnity Jan 5, 2023
27608a0
update - tick replacing sent time
NoelStephensUnity Jan 5, 2023
87396d5
update
NoelStephensUnity Jan 7, 2023
543c7e8
test manual
NoelStephensUnity Jan 7, 2023
27da0c2
update - synchronize transform
NoelStephensUnity Jan 7, 2023
84d3961
update - quaternion compression
NoelStephensUnity Jan 7, 2023
0d53a97
test - manual Bandwidth Test
NoelStephensUnity Jan 7, 2023
ec0eda4
update
NoelStephensUnity Jan 7, 2023
efdb3be
update
NoelStephensUnity Jan 7, 2023
e7f0517
update
NoelStephensUnity Jan 8, 2023
7c25236
update
NoelStephensUnity Jan 9, 2023
e045bc2
update
NoelStephensUnity Jan 9, 2023
f248e37
test
NoelStephensUnity Jan 9, 2023
50f4d68
update
NoelStephensUnity Jan 9, 2023
a40ca24
update
NoelStephensUnity Jan 9, 2023
f8551c8
update
NoelStephensUnity Jan 9, 2023
12864ef
test
NoelStephensUnity Jan 9, 2023
0b69779
update
NoelStephensUnity Jan 9, 2023
7676b57
test
NoelStephensUnity Jan 9, 2023
a7f545c
update
NoelStephensUnity Jan 10, 2023
3bbf8a7
test
NoelStephensUnity Jan 10, 2023
34795f5
test manual
NoelStephensUnity Jan 10, 2023
ba5444c
Merge branch 'develop' into refactor/quaternion-synchronization-netwo…
NoelStephensUnity Jan 10, 2023
8d27739
style
NoelStephensUnity Jan 10, 2023
85f0ec5
style
NoelStephensUnity Jan 10, 2023
877dffd
test
NoelStephensUnity Jan 11, 2023
79f44f3
style
NoelStephensUnity Jan 11, 2023
c02b81f
update
NoelStephensUnity Jan 11, 2023
af27d8f
style
NoelStephensUnity Jan 11, 2023
b4777a8
update
NoelStephensUnity Jan 11, 2023
28b996c
fix
NoelStephensUnity Jan 11, 2023
90d6ddb
fix
NoelStephensUnity Jan 11, 2023
c76d797
style
NoelStephensUnity Jan 11, 2023
55697ac
update
NoelStephensUnity Jan 11, 2023
1aedc03
update
NoelStephensUnity Jan 12, 2023
2b2ab9b
update
NoelStephensUnity Jan 12, 2023
23af3b7
Merge branch 'develop' into refactor/quaternion-synchronization-netwo…
NoelStephensUnity Jan 13, 2023
cf93c82
update
NoelStephensUnity Jan 13, 2023
6dc3b42
Merge branch 'develop' into feat/quaternion-synchronization-network-t…
NoelStephensUnity Jan 19, 2023
922999d
update
NoelStephensUnity Jan 20, 2023
10032f1
update
NoelStephensUnity Jan 28, 2023
1f16c44
test manual
NoelStephensUnity Jan 28, 2023
f7a0e09
Merge branch 'develop' into feat/quaternion-synchronization-network-t…
NoelStephensUnity Jan 31, 2023
9569e00
Merge branch 'develop' into feat/quaternion-synchronization-network-t…
NoelStephensUnity Feb 2, 2023
cb42fe5
Merge branch 'develop' into feat/quaternion-synchronization-network-t…
NoelStephensUnity Feb 7, 2023
cd4a5f2
Merge branch 'develop' into feat/quaternion-synchronization-network-t…
NoelStephensUnity Feb 16, 2023
a06cc6c
fix - merging parent dynamic under in scene placed
NoelStephensUnity Feb 16, 2023
049d6f5
update
NoelStephensUnity Feb 16, 2023
3666fde
Test Manual
NoelStephensUnity Feb 16, 2023
bd02a59
Merge branch 'develop' into feat/quaternion-synchronization-network-t…
NoelStephensUnity Feb 16, 2023
348d949
update
NoelStephensUnity Feb 16, 2023
53f2172
update
NoelStephensUnity Feb 16, 2023
4705932
style
NoelStephensUnity Feb 16, 2023
68e1f15
test
NoelStephensUnity Feb 21, 2023
221fa44
update
NoelStephensUnity Feb 21, 2023
0d9709a
update and style
NoelStephensUnity Feb 21, 2023
5813345
update
NoelStephensUnity Feb 23, 2023
8454f9d
test
NoelStephensUnity Feb 23, 2023
906a3ab
update
NoelStephensUnity Feb 24, 2023
3649e6c
test
NoelStephensUnity Feb 24, 2023
e97320b
update
NoelStephensUnity Feb 24, 2023
19bbfad
test manual
NoelStephensUnity Feb 24, 2023
d550f61
update and style
NoelStephensUnity Feb 24, 2023
484edc4
Merge branch 'develop' into feat/quaternion-synchronization-network-t…
NoelStephensUnity Feb 24, 2023
177fad4
changelog fix
NoelStephensUnity Feb 24, 2023
d616c0c
Merge branch 'develop' into feat/quaternion-synchronization-network-t…
NoelStephensUnity Mar 1, 2023
5c8a2ab
update
NoelStephensUnity Mar 1, 2023
c4f74c5
update
NoelStephensUnity Mar 2, 2023
5c31ae5
test
NoelStephensUnity Mar 2, 2023
24ebf6d
Merge branch 'develop' into feat/quaternion-synchronization-network-t…
NoelStephensUnity Mar 2, 2023
5d7cf3b
fix
NoelStephensUnity Mar 2, 2023
2308eb5
Merge branch 'develop' into feat/quaternion-synchronization-network-t…
NoelStephensUnity Mar 3, 2023
1798926
Merge branch 'develop' into feat/quaternion-synchronization-network-t…
NoelStephensUnity Mar 3, 2023
06de0f2
update
NoelStephensUnity Mar 3, 2023
7957230
Merge branch 'develop' into feat/quaternion-synchronization-network-t…
NoelStephensUnity Mar 3, 2023
2b7822b
Merge branch 'develop' into feat/quaternion-synchronization-network-t…
NoelStephensUnity Mar 6, 2023
3a906ae
revert
NoelStephensUnity Mar 6, 2023
505ed65
Merge branch 'develop' into feat/quaternion-synchronization-network-t…
NoelStephensUnity Mar 10, 2023
57588e8
update
NoelStephensUnity Mar 10, 2023
144a4b8
Merge branch 'develop' into feat/quaternion-synchronization-network-t…
NoelStephensUnity Mar 10, 2023
a76c804
style
NoelStephensUnity Mar 10, 2023
70b4f65
style
NoelStephensUnity Mar 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion com.unity.netcode.gameobjects/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,30 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
Additional documentation and release notes are available at [Multiplayer Documentation](https://docs-multiplayer.unity3d.com).

## [Unreleased]

### Added

- Added `NetworkTransform.UseHalfFloatPrecision` property that, when enabled, will use half float values for position, rotation, and scale. This yields a 50% bandwidth savings a the cost of precision. (#2388)
- Added `NetworkTransform.UseQuaternionSynchronization` property that, when enabled, will synchronize the entire quaternion. (#2388)
- Added `NetworkTransform.UseQuaternionCompression` property that, when enabled, will use a smallest three implementation reducing a full quaternion synchronization update to the size of an unsigned integer. (#2388)
- Added `NetworkTransform.SlerpPosition` property that, when enabled along with interpolation being enabled, will interpolate using `Vector3.Slerp`. (#2388)
- Added `BufferedLinearInterpolatorVector3` that replaces the float version, is now used by `NetworkTransform`, and provides the ability to enable or disable `Slerp`. (#2388)
- Added `HalfVector3` used for scale when half float precision is enabled. (#2388)
- Added `HalfVector4` used for rotation when half float precision and quaternion synchronization is enabled. (#2388)
- Added `HalfVector3DeltaPosition` used for position when half float precision is enabled. This handles loss in position precision by updating only the delta position as opposed to the full position. (#2388)
- Added `NetworkTransform.GetSpaceRelativePosition` and `NetworkTransform.GetSpaceRelativeRotation` helper methods to return the proper values depending upon whether local or world space. (#2388)
- Added `NetworkTransform.OnAuthorityPushTransformState` virtual method that is invoked just prior to sending the `NetworkTransformState` to non-authoritative instances. This provides users with the ability to obtain more precise delta values for prediction related calculations. (#2388)
- Added `NetworkTransform.OnNetworkTransformStateUpdated` virtual method that is invoked just after the authoritative `NetworkTransformState` is applied. This provides users with the ability to obtain more precise delta values for prediction related calculations. (#2388)
- Added `NetworkTransform.OnInitialize`virtual method that is invoked after the `NetworkTransform` has been initialized or re-initialized when ownership changes. This provides for a way to make adjustments when `NetworkTransform` is initialized (i.e. resetting client prediction etc) (#2388)
- Added `NetworkObject.SynchronizeTransform` property (default is true) that provides users with another way to help with bandwidth optimizations where, when set to false, the `NetworkObject`'s associated transform will not be included when spawning and/or synchronizing late joining players. (#2388)
- Added `NetworkSceneManager.ActiveSceneSynchronizationEnabled` property, disabled by default, that enables client synchronization of server-side active scene changes. (#2383)
- Added `NetworkObject.ActiveSceneSynchronization`, disabled by default, that will automatically migrate a `NetworkObject` to a newly assigned active scene. (#2383)
- Added `NetworkObject.SceneMigrationSynchronization`, enabled by default, that will synchronize client(s) when a `NetworkObject` is migrated into a new scene on the server side via `SceneManager.MoveGameObjectToScene`. (#2383)

### Changed

- Changed `NetworkTransform` authority handles delta checks on each new network tick and no longer consumes processing cycles checking for deltas for all frames in-between ticks. (#2388)
- Changed the `NetworkTransformState` structure is now public and now has public methods that provide access to key properties of the `NetworkTransformState` structure. (#2388)
- Changed `NetworkTransform` interpolation adjusts its interpolation "ticks ago" to be 2 ticks latent if it is owner authoritative and the instance is not the server or 1 tick latent if the instance is the server and/or is server authoritative. (#2388)
- Updated `NetworkSceneManager` to migrate dynamically spawned `NetworkObject`s with `DestroyWithScene` set to false into the active scene if their current scene is unloaded. (#2383)
- Updated the server to synchronize its local `NetworkSceneManager.ClientSynchronizationMode` during the initial client synchronization. (#2383)

Expand All @@ -25,6 +40,8 @@ Additional documentation and release notes are available at [Multiplayer Documen
- Fixed registry of public `NetworkVariable`s in derived `NetworkBehaviour`s (#2423)
- Fixed issue where runtime association of `Animator` properties to `AnimationCurve`s would cause `NetworkAnimator` to attempt to update those changes. (#2416)
- Fixed issue where `NetworkAnimator` would not check if its associated `Animator` was valid during serialization and would spam exceptions in the editor console. (#2416)
- Fixed issue with a child's rotation rolling over when interpolation is enabled on a `NetworkTransform`. Now using half precision or full quaternion synchronization will always update all axis. (#2388)
- Fixed issue where `NetworkTransform` was not setting the teleport flag when the `NetworkTransform.InLocalSpace` value changed. This issue only impacted `NetworkTransform` when interpolation was enabled. (#2388)
- Fixed issue when the `NetworkSceneManager.ClientSynchronizationMode` is `LoadSceneMode.Additive` and the server changes the currently active scene prior to a client connecting then upon a client connecting and being synchronized the NetworkSceneManager would clear its internal ScenePlacedObjects list that could already be populated. (#2383)
- Fixed issue where a client would load duplicate scenes of already preloaded scenes during the initial client synchronization and `NetworkSceneManager.ClientSynchronizationMode` was set to `LoadSceneMode.Additive`. (#2383)
- Fixed float NetworkVariables not being rendered properly in the inspector of NetworkObjects. (#2441)
Expand Down
131 changes: 131 additions & 0 deletions com.unity.netcode.gameobjects/Components/HalfVector3.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
using System.Runtime.CompilerServices;
using UnityEngine;

namespace Unity.Netcode.Components
{
/// <summary>
/// Half float precision <see cref="Vector3"/>.
/// </summary>
/// <remarks>
/// The Vector3T<ushort> values are half float values returned by <see cref="Mathf.FloatToHalf(float)"/> for each
/// individual axis and the 16 bits of the half float are stored as <see cref="ushort"/> values since C# does not have
/// a half float type.
/// </remarks>
public struct HalfVector3 : INetworkSerializable
{
/// <summary>
/// The half float precision value of the x-axis as a <see cref="ushort"/>.
/// </summary>
public ushort X => Axis.X;
/// <summary>
/// The half float precision value of the y-axis as a <see cref="ushort"/>.
/// </summary>
public ushort Y => Axis.Y;
/// <summary>
/// The half float precision value of the z-axis as a <see cref="ushort"/>.
/// </summary>
public ushort Z => Axis.Z;

/// <summary>
/// Used to store the half float precision value as a <see cref="ushort"/>.
/// </summary>
public Vector3T<ushort> Axis;

internal Vector3AxisToSynchronize AxisToSynchronize;

/// <summary>
/// The serialization implementation of <see cref="INetworkSerializable"/>.
/// </summary>
public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
{
for (int i = 0; i < Axis.Length; i++)
{
if (AxisToSynchronize.SyncAxis[i])
{
var axisValue = Axis[i];
serializer.SerializeValue(ref axisValue);
Comment thread
NoelStephensUnity marked this conversation as resolved.
if (serializer.IsReader)
{
Axis[i] = axisValue;
}
}
}
}

/// <summary>
/// Gets the full precision value as a <see cref="Vector3"/>.
/// </summary>
/// <returns>a <see cref="Vector3"/> as the full precision value.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Vector3 ToVector3()
{
Vector3 fullPrecision = Vector3.zero;
for (int i = 0; i < Axis.Length; i++)
{
if (AxisToSynchronize.SyncAxis[i])
{
fullPrecision[i] = Mathf.HalfToFloat(Axis[i]);
}
}
return fullPrecision;
}

/// <summary>
/// Converts a full precision <see cref="Vector3"/> to half precision and updates the current instance.
/// </summary>
/// <param name="vector3">The <see cref="Vector3"/> to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void UpdateFrom(ref Vector3 vector3)
{
for (int i = 0; i < Axis.Length; i++)
{
if (AxisToSynchronize.SyncAxis[i])
{
Axis[i] = Mathf.FloatToHalf(vector3[i]);
}
}
}

/// <summary>
/// Constructor
/// </summary>
/// <param name="vector3">The initial axial values (converted to half floats) when instantiated.</param>
/// <param name="vector3AxisToSynchronize">The axis to synchronize.</param>
public HalfVector3(Vector3 vector3, Vector3AxisToSynchronize vector3AxisToSynchronize)
{
Axis = default;
AxisToSynchronize = vector3AxisToSynchronize;
UpdateFrom(ref vector3);
}

/// <summary>
/// Constructor that defaults to all axis being synchronized.
/// </summary>
/// <param name="vector3">The initial axial values (converted to half floats) when instantiated.</param>
public HalfVector3(Vector3 vector3) : this(vector3, Vector3AxisToSynchronize.AllAxis)
{

}

/// <summary>
/// Constructor
/// </summary>
/// <param name="x">The initial x axis (converted to half float) value when instantiated.</param>
/// <param name="y">The initial y axis (converted to half float) value when instantiated.</param>
/// <param name="z">The initial z axis (converted to half float) value when instantiated.</param>
/// <param name="vector3AxisToSynchronize">The axis to synchronize.</param>
public HalfVector3(float x, float y, float z, Vector3AxisToSynchronize vector3AxisToSynchronize) : this(new Vector3(x, y, z), vector3AxisToSynchronize)
{
}

/// <summary>
/// Constructor that defaults to all axis being synchronized.
/// </summary>
/// <param name="x">The initial x axis (converted to half float) value when instantiated.</param>
/// <param name="y">The initial y axis (converted to half float) value when instantiated.</param>
/// <param name="z">The initial z axis (converted to half float) value when instantiated.</param>
public HalfVector3(float x, float y, float z) : this(new Vector3(x, y, z), Vector3AxisToSynchronize.AllAxis)
{
}
}
}
11 changes: 11 additions & 0 deletions com.unity.netcode.gameobjects/Components/HalfVector3.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading