Skip to content
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

fix: networktransform double lerp (MTTB-539) #3337

Open
wants to merge 46 commits into
base: develop-2.0.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
6eadea1
update
NoelStephensUnity Feb 26, 2025
861dbf1
update
NoelStephensUnity Feb 27, 2025
d5dfc63
style
NoelStephensUnity Feb 27, 2025
45ed0e1
update
NoelStephensUnity Feb 27, 2025
2e40494
update
NoelStephensUnity Feb 27, 2025
b784e14
update
NoelStephensUnity Mar 2, 2025
08f261c
update
NoelStephensUnity Mar 4, 2025
4ce6c50
update
NoelStephensUnity Mar 4, 2025
4d691dc
update
NoelStephensUnity Mar 4, 2025
a8a51e2
update
NoelStephensUnity Mar 5, 2025
36ed15d
Merge branch 'develop-2.0.0' into fix/networktransform-double-lerp-MT…
NoelStephensUnity Mar 5, 2025
de3094f
fix
NoelStephensUnity Mar 5, 2025
15c8e59
update
NoelStephensUnity Mar 5, 2025
283ab9f
fix
NoelStephensUnity Mar 5, 2025
e1f6763
fix
NoelStephensUnity Mar 5, 2025
7b770a4
fix
NoelStephensUnity Mar 5, 2025
6562b90
test
NoelStephensUnity Mar 5, 2025
1cf4f3d
fix
NoelStephensUnity Mar 5, 2025
ccd5026
test
NoelStephensUnity Mar 5, 2025
f3d564e
fix
NoelStephensUnity Mar 5, 2025
877f4cc
update
NoelStephensUnity Mar 6, 2025
69480f0
test
NoelStephensUnity Mar 6, 2025
d7f14dc
update
NoelStephensUnity Mar 6, 2025
7d02134
test
NoelStephensUnity Mar 6, 2025
fc9ee50
test and update
NoelStephensUnity Mar 6, 2025
a5d9bf8
Test
NoelStephensUnity Mar 6, 2025
e5dc365
update
NoelStephensUnity Mar 6, 2025
d917530
update
NoelStephensUnity Mar 6, 2025
91eca5f
style
NoelStephensUnity Mar 6, 2025
639fbf8
update - pvp
NoelStephensUnity Mar 6, 2025
f369d09
update - pvp
NoelStephensUnity Mar 6, 2025
be8e176
style
NoelStephensUnity Mar 6, 2025
7000fae
update
NoelStephensUnity Mar 6, 2025
0fe85d2
test
NoelStephensUnity Mar 6, 2025
e453cdf
update
NoelStephensUnity Mar 6, 2025
f649ba4
Merge branch 'develop-2.0.0' into fix/networktransform-double-lerp-MT…
NoelStephensUnity Mar 6, 2025
bed3a33
style
NoelStephensUnity Mar 7, 2025
4121985
Merge branch 'fix/networktransform-double-lerp-MTTB-539' of https://g…
NoelStephensUnity Mar 7, 2025
354b036
update
NoelStephensUnity Mar 7, 2025
15a6f9f
update
NoelStephensUnity Mar 7, 2025
bdb9586
Merge branch 'develop-2.0.0' into fix/networktransform-double-lerp-MT…
NoelStephensUnity Mar 7, 2025
a51365f
update
NoelStephensUnity Mar 7, 2025
536da81
Merge branch 'fix/networktransform-double-lerp-MTTB-539' of https://g…
NoelStephensUnity Mar 7, 2025
ee37977
update
NoelStephensUnity Mar 7, 2025
08dc79a
update
NoelStephensUnity Mar 7, 2025
4fe72f5
update
NoelStephensUnity Mar 8, 2025
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
5 changes: 5 additions & 0 deletions com.unity.netcode.gameobjects/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ Additional documentation and release notes are available at [Multiplayer Documen

### Added

- Added interpolator types as an inspector view selection for position, rotation, and scale. (#3337)
- Added a new smooth dampening interpolator type that provides a nice balance between precision and smoothing results. (#3337)
- Added `NetworkTimeSystem.TickLatency` property that provides the average latency of a client. (#3337)
- Added `FastBufferReader(ArraySegment<byte> buffer, Allocator copyAllocator)` constructor that uses the `ArraySegment.Offset` as the `FastBufferReader` offset and the `ArraySegment.Count` as the `FastBufferReader` length. (#3321)
- Added `FastBufferReader(ArraySegment<byte> buffer, Allocator copyAllocator, int length = -1)` constructor that uses the `ArraySegment.Offset` as the `FastBufferReader` offset. (#3321)

### Fixed

- Fixed issue where the `MaximumInterpolationTime` could not be modified from within the inspector view or runtime. (#3337)
- Fixed `ChangeOwnership` changing ownership to clients that are not observers. This also happened with automated object distribution. (#3323)
- Fixed issue where `AnticipatedNetworkVariable` previous value returned by `AnticipatedNetworkVariable.OnAuthoritativeValueChanged` is updated correctly on the non-authoritative side. (#3306)
- Fixed `OnClientConnectedCallback` passing incorrect `clientId` when scene management is disabled. (#3312)
Expand All @@ -31,6 +35,7 @@ Additional documentation and release notes are available at [Multiplayer Documen

### Changed

- Changed `BufferedLinearInterpolator<T>.Update(float deltaTime, NetworkTime serverTime)` as being deprecated since this method is only used for internal testing purposes. (#3337)
- Ensured that a useful error is thrown when attempting to build a dedicated server with Unity Transport that uses websockets. (#3336)
- Changed root in-scene placed `NetworkObject` instances now will always have either the `Distributable` permission set unless the `SessionOwner` permission is set. (#3305)
- Changed the `DestroyObject` message to reduce the serialized message size and remove the unnecessary message field. (#3304)
Expand Down
19 changes: 19 additions & 0 deletions com.unity.netcode.gameobjects/Editor/NetcodeEditorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,30 @@ namespace Unity.Netcode.Editor
[CanEditMultipleObjects]
public partial class NetcodeEditorBase<TT> : UnityEditor.Editor where TT : MonoBehaviour
{
private const int k_IndentOffset = 15;

/// <inheritdoc cref="UnityEditor.Editor.OnEnable"/>
public virtual void OnEnable()
{
}

/// <summary>
/// Will draw a property field with an indention level using the default or a specified offset per indention.
/// </summary>
/// <param name="property">The serialized property to draw as a default field</param>
/// <param name="indentLevel">The indention level.</param>
/// <param name="offset">Optional indention level offset.</param>
protected internal void DrawIndentedPropertyField(SerializedProperty property, int indentLevel, int offset = k_IndentOffset)
{
var originalWidth = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = originalWidth - (indentLevel * offset);
EditorGUILayout.BeginHorizontal();
EditorGUILayout.Space(indentLevel * offset, false);
EditorGUILayout.PropertyField(property, GUILayout.ExpandWidth(true));
EditorGUILayout.EndHorizontal();
EditorGUIUtility.labelWidth = originalWidth;
}

/// <summary>
/// Helper method to draw the properties of the specified child type <typeparamref name="T"/> component within a FoldoutHeaderGroup.
/// </summary>
Expand Down
70 changes: 64 additions & 6 deletions com.unity.netcode.gameobjects/Editor/NetworkTransformEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ public class NetworkTransformEditor : NetcodeEditorBase<NetworkTransform>
private SerializedProperty m_ScaleThresholdProperty;
private SerializedProperty m_InLocalSpaceProperty;
private SerializedProperty m_InterpolateProperty;
private SerializedProperty m_PositionInterpolationTypeProperty;
private SerializedProperty m_RotationInterpolationTypeProperty;
private SerializedProperty m_ScaleInterpolationTypeProperty;

private SerializedProperty m_PositionMaximumInterpolationTimeProperty;
private SerializedProperty m_RotationMaximumInterpolationTimeProperty;
private SerializedProperty m_ScaleMaximumInterpolationTimeProperty;

private SerializedProperty m_UseQuaternionSynchronization;
private SerializedProperty m_UseQuaternionCompression;
Expand All @@ -36,6 +43,7 @@ public class NetworkTransformEditor : NetcodeEditorBase<NetworkTransform>
private SerializedProperty m_AuthorityMode;

private static int s_ToggleOffset = 45;

private static float s_MaxRowWidth = EditorGUIUtility.labelWidth + EditorGUIUtility.fieldWidth + 5;
private static GUIContent s_PositionLabel = EditorGUIUtility.TrTextContent("Position");
private static GUIContent s_RotationLabel = EditorGUIUtility.TrTextContent("Rotation");
Expand All @@ -61,6 +69,15 @@ public override void OnEnable()
m_ScaleThresholdProperty = serializedObject.FindProperty(nameof(NetworkTransform.ScaleThreshold));
m_InLocalSpaceProperty = serializedObject.FindProperty(nameof(NetworkTransform.InLocalSpace));
m_InterpolateProperty = serializedObject.FindProperty(nameof(NetworkTransform.Interpolate));

m_PositionInterpolationTypeProperty = serializedObject.FindProperty(nameof(NetworkTransform.PositionInterpolationType));
m_PositionMaximumInterpolationTimeProperty = serializedObject.FindProperty(nameof(NetworkTransform.PositionMaxInterpolationTime));
m_RotationInterpolationTypeProperty = serializedObject.FindProperty(nameof(NetworkTransform.RotationInterpolationType));
m_RotationMaximumInterpolationTimeProperty = serializedObject.FindProperty(nameof(NetworkTransform.RotationMaxInterpolationTime));
m_ScaleInterpolationTypeProperty = serializedObject.FindProperty(nameof(NetworkTransform.ScaleInterpolationType));
m_ScaleMaximumInterpolationTimeProperty = serializedObject.FindProperty(nameof(NetworkTransform.ScaleMaxInterpolationTime));


m_UseQuaternionSynchronization = serializedObject.FindProperty(nameof(NetworkTransform.UseQuaternionSynchronization));
m_UseQuaternionCompression = serializedObject.FindProperty(nameof(NetworkTransform.UseQuaternionCompression));
m_UseHalfFloatPrecision = serializedObject.FindProperty(nameof(NetworkTransform.UseHalfFloatPrecision));
Expand Down Expand Up @@ -141,9 +158,21 @@ private void DisplayNetworkTransformProperties()
}
EditorGUILayout.Space();
EditorGUILayout.LabelField("Thresholds", EditorStyles.boldLabel);
EditorGUILayout.PropertyField(m_PositionThresholdProperty);
EditorGUILayout.PropertyField(m_RotAngleThresholdProperty);
EditorGUILayout.PropertyField(m_ScaleThresholdProperty);
if (networkTransform.SynchronizePosition)
{
EditorGUILayout.PropertyField(m_PositionThresholdProperty);
}

if (networkTransform.SynchronizeRotation)
{
EditorGUILayout.PropertyField(m_RotAngleThresholdProperty);
}

if (networkTransform.SynchronizeScale)
{
EditorGUILayout.PropertyField(m_ScaleThresholdProperty);
}

EditorGUILayout.Space();
EditorGUILayout.LabelField("Delivery", EditorStyles.boldLabel);
EditorGUILayout.PropertyField(m_TickSyncChildren);
Expand All @@ -159,8 +188,39 @@ private void DisplayNetworkTransformProperties()
if (!networkTransform.HideInterpolateValue)
{
EditorGUILayout.PropertyField(m_InterpolateProperty);
if (networkTransform.Interpolate)
{
if (networkTransform.SynchronizePosition)
{
DrawIndentedPropertyField(m_PositionInterpolationTypeProperty, 1);
// Only display when using Lerp.
if (networkTransform.PositionInterpolationType == NetworkTransform.InterpolationTypes.Lerp)
{
DrawIndentedPropertyField(m_SlerpPosition, 2);
DrawIndentedPropertyField(m_PositionMaximumInterpolationTimeProperty, 2);
}
}
if (networkTransform.SynchronizeRotation)
{
DrawIndentedPropertyField(m_RotationInterpolationTypeProperty, 1);
// Only display when using Lerp.
if (networkTransform.RotationInterpolationType == NetworkTransform.InterpolationTypes.Lerp)
{
DrawIndentedPropertyField(m_RotationMaximumInterpolationTimeProperty, 2);
}
}
if (networkTransform.SynchronizeScale)
{
DrawIndentedPropertyField(m_ScaleInterpolationTypeProperty, 1);
// Only display when using Lerp.
if (networkTransform.ScaleInterpolationType == NetworkTransform.InterpolationTypes.Lerp)
{
DrawIndentedPropertyField(m_ScaleMaximumInterpolationTimeProperty, 2);
}
}
}
}
EditorGUILayout.PropertyField(m_SlerpPosition);

EditorGUILayout.PropertyField(m_UseQuaternionSynchronization);
if (m_UseQuaternionSynchronization.boolValue)
{
Expand Down Expand Up @@ -190,8 +250,6 @@ private void DisplayNetworkTransformProperties()
#endif // COM_UNITY_MODULES_PHYSICS2D
}



/// <inheritdoc/>
public override void OnInspectorGUI()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ private void SerializeRead(FastBufferReader reader)
}
}

/// <summary>
/// The serialization implementation of <see cref="INetworkSerializable"/>.
/// </summary>
/// <inheritdoc />
public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
{
if (serializer.IsReader)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ private void SerializeRead(FastBufferReader reader)
}
}

/// <summary>
/// The serialization implementation of <see cref="INetworkSerializable"/>.
/// </summary>
/// <inheritdoc />
public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
{
if (serializer.IsReader)
Expand Down
Loading