com.unity.netcode.gameobjects@1.0.0-pre.8
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Additional documentation and release notes are available at [Multiplayer Documentation](https://docs-multiplayer.unity3d.com). ## [1.0.0-pre.8] - 2022-04-27 ### Changed - `unmanaged` structs are no longer universally accepted as RPC parameters because some structs (i.e., structs with pointers in them, such as `NativeList<T>`) can't be supported by the default memcpy struct serializer. Structs that are intended to be serialized across the network must add `INetworkSerializeByMemcpy` to the interface list (i.e., `struct Foo : INetworkSerializeByMemcpy`). This interface is empty and just serves to mark the struct as compatible with memcpy serialization. For external structs you can't edit, you can pass them to RPCs by wrapping them in `ForceNetworkSerializeByMemcpy<T>`. (#1901) ### Removed - Removed `SIPTransport` (#1870) - Removed `ClientNetworkTransform` from the package samples and moved to Boss Room's Utilities package which can be found [here](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Packages/com.unity.multiplayer.samples.coop/Utilities/Net/ClientAuthority/ClientNetworkTransform.cs). ### Fixed - Fixed `NetworkTransform` generating false positive rotation delta checks when rolling over between 0 and 360 degrees. (#1890) - Fixed client throwing an exception if it has messages in the outbound queue when processing the `NetworkEvent.Disconnect` event and is using UTP. (#1884) - Fixed issue during client synchronization if 'ValidateSceneBeforeLoading' returned false it would halt the client synchronization process resulting in a client that was approved but not synchronized or fully connected with the server. (#1883) - Fixed an issue where UNetTransport.StartServer would return success even if the underlying transport failed to start (#854) - Passing generic types to RPCs no longer causes a native crash (#1901) - Fixed an issue where calling `Shutdown` on a `NetworkManager` that was already shut down would cause an immediate shutdown the next time it was started (basically the fix makes `Shutdown` idempotent). (#1877)
This commit is contained in:
@@ -22,6 +22,11 @@ namespace Unity.Netcode.RuntimeTests
|
||||
|
||||
ReadyToReceivePositionUpdate = true;
|
||||
}
|
||||
|
||||
public (bool isDirty, bool isPositionDirty, bool isRotationDirty, bool isScaleDirty) ApplyState()
|
||||
{
|
||||
return ApplyLocalNetworkState(transform);
|
||||
}
|
||||
}
|
||||
|
||||
// [TestFixture(true, true)]
|
||||
@@ -172,6 +177,80 @@ namespace Unity.Netcode.RuntimeTests
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Validates that rotation checks don't produce false positive
|
||||
/// results when rolling over between 0 and 360 degrees
|
||||
/// </summary>
|
||||
[UnityTest]
|
||||
public IEnumerator TestRotationThresholdDeltaCheck()
|
||||
{
|
||||
// Get the client player's NetworkTransform for both instances
|
||||
var authoritativeNetworkTransform = m_ServerSideClientPlayer.GetComponent<NetworkTransformTestComponent>();
|
||||
var otherSideNetworkTransform = m_ClientSideClientPlayer.GetComponent<NetworkTransformTestComponent>();
|
||||
otherSideNetworkTransform.RotAngleThreshold = authoritativeNetworkTransform.RotAngleThreshold = 5.0f;
|
||||
|
||||
var halfThreshold = authoritativeNetworkTransform.RotAngleThreshold * 0.5001f;
|
||||
var serverRotation = authoritativeNetworkTransform.transform.rotation;
|
||||
var serverEulerRotation = serverRotation.eulerAngles;
|
||||
|
||||
// Verify rotation is not marked dirty when rotated by half of the threshold
|
||||
serverEulerRotation.y += halfThreshold;
|
||||
serverRotation.eulerAngles = serverEulerRotation;
|
||||
authoritativeNetworkTransform.transform.rotation = serverRotation;
|
||||
var results = authoritativeNetworkTransform.ApplyState();
|
||||
Assert.IsFalse(results.isRotationDirty, $"Rotation is dirty when rotation threshold is {authoritativeNetworkTransform.RotAngleThreshold} degrees and only adjusted by {halfThreshold} degrees!");
|
||||
yield return s_DefaultWaitForTick;
|
||||
|
||||
// Verify rotation is marked dirty when rotated by another half threshold value
|
||||
serverEulerRotation.y += halfThreshold;
|
||||
serverRotation.eulerAngles = serverEulerRotation;
|
||||
authoritativeNetworkTransform.transform.rotation = serverRotation;
|
||||
results = authoritativeNetworkTransform.ApplyState();
|
||||
Assert.IsTrue(results.isRotationDirty, $"Rotation was not dirty when rotated by the threshold value: {authoritativeNetworkTransform.RotAngleThreshold} degrees!");
|
||||
yield return s_DefaultWaitForTick;
|
||||
|
||||
//Reset rotation back to zero on all axis
|
||||
serverRotation.eulerAngles = serverEulerRotation = Vector3.zero;
|
||||
authoritativeNetworkTransform.transform.rotation = serverRotation;
|
||||
yield return s_DefaultWaitForTick;
|
||||
|
||||
// Rotate by 360 minus halfThreshold (which is really just negative halfThreshold) and verify rotation is not marked dirty
|
||||
serverEulerRotation.y = 360 - halfThreshold;
|
||||
serverRotation.eulerAngles = serverEulerRotation;
|
||||
authoritativeNetworkTransform.transform.rotation = serverRotation;
|
||||
results = authoritativeNetworkTransform.ApplyState();
|
||||
|
||||
Assert.IsFalse(results.isRotationDirty, $"Rotation is dirty when rotation threshold is {authoritativeNetworkTransform.RotAngleThreshold} degrees and only adjusted by " +
|
||||
$"{Mathf.DeltaAngle(0, serverEulerRotation.y)} degrees!");
|
||||
|
||||
serverEulerRotation.y -= halfThreshold;
|
||||
serverRotation.eulerAngles = serverEulerRotation;
|
||||
authoritativeNetworkTransform.transform.rotation = serverRotation;
|
||||
results = authoritativeNetworkTransform.ApplyState();
|
||||
|
||||
Assert.IsTrue(results.isRotationDirty, $"Rotation was not dirty when rotated by {Mathf.DeltaAngle(0, serverEulerRotation.y)} degrees!");
|
||||
|
||||
//Reset rotation back to zero on all axis
|
||||
serverRotation.eulerAngles = serverEulerRotation = Vector3.zero;
|
||||
authoritativeNetworkTransform.transform.rotation = serverRotation;
|
||||
yield return s_DefaultWaitForTick;
|
||||
|
||||
serverEulerRotation.y -= halfThreshold;
|
||||
serverRotation.eulerAngles = serverEulerRotation;
|
||||
authoritativeNetworkTransform.transform.rotation = serverRotation;
|
||||
results = authoritativeNetworkTransform.ApplyState();
|
||||
Assert.IsFalse(results.isRotationDirty, $"Rotation is dirty when rotation threshold is {authoritativeNetworkTransform.RotAngleThreshold} degrees and only adjusted by " +
|
||||
$"{Mathf.DeltaAngle(0, serverEulerRotation.y)} degrees!");
|
||||
|
||||
serverEulerRotation.y -= halfThreshold;
|
||||
serverRotation.eulerAngles = serverEulerRotation;
|
||||
authoritativeNetworkTransform.transform.rotation = serverRotation;
|
||||
results = authoritativeNetworkTransform.ApplyState();
|
||||
|
||||
Assert.IsTrue(results.isRotationDirty, $"Rotation was not dirty when rotated by {Mathf.DeltaAngle(0, serverEulerRotation.y)} degrees!");
|
||||
}
|
||||
|
||||
/*
|
||||
* ownership change
|
||||
* test teleport with interpolation
|
||||
|
||||
Reference in New Issue
Block a user