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)
68 lines
3.5 KiB
C#
68 lines
3.5 KiB
C#
#if COM_UNITY_MODULES_PHYSICS
|
|
using System.Collections;
|
|
using NUnit.Framework;
|
|
using Unity.Netcode.Components;
|
|
using UnityEngine;
|
|
using UnityEngine.TestTools;
|
|
using Unity.Netcode.TestHelpers.Runtime;
|
|
|
|
namespace Unity.Netcode.RuntimeTests
|
|
{
|
|
public class NetworkRigidbodyTest : NetcodeIntegrationTest
|
|
{
|
|
protected override int NumberOfClients => 1;
|
|
|
|
protected override void OnCreatePlayerPrefab()
|
|
{
|
|
m_PlayerPrefab.AddComponent<NetworkTransform>();
|
|
m_PlayerPrefab.AddComponent<Rigidbody>();
|
|
m_PlayerPrefab.AddComponent<NetworkRigidbody>();
|
|
m_PlayerPrefab.GetComponent<Rigidbody>().interpolation = RigidbodyInterpolation.Interpolate;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Tests that a server can destroy a NetworkObject and that it gets despawned correctly.
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[UnityTest]
|
|
public IEnumerator TestRigidbodyKinematicEnableDisable()
|
|
{
|
|
// This is the *SERVER VERSION* of the *CLIENT PLAYER*
|
|
var serverClientPlayerResult = new NetcodeIntegrationTestHelpers.ResultWrapper<NetworkObject>();
|
|
yield return NetcodeIntegrationTestHelpers.GetNetworkObjectByRepresentation((x => x.IsPlayerObject && x.OwnerClientId == m_ClientNetworkManagers[0].LocalClientId), m_ServerNetworkManager, serverClientPlayerResult);
|
|
var serverPlayer = serverClientPlayerResult.Result.gameObject;
|
|
|
|
// This is the *CLIENT VERSION* of the *CLIENT PLAYER*
|
|
var clientClientPlayerResult = new NetcodeIntegrationTestHelpers.ResultWrapper<NetworkObject>();
|
|
yield return NetcodeIntegrationTestHelpers.GetNetworkObjectByRepresentation((x => x.IsPlayerObject && x.OwnerClientId == m_ClientNetworkManagers[0].LocalClientId), m_ClientNetworkManagers[0], clientClientPlayerResult);
|
|
var clientPlayer = clientClientPlayerResult.Result.gameObject;
|
|
|
|
Assert.IsNotNull(serverPlayer, "serverPlayer is not null");
|
|
Assert.IsNotNull(clientPlayer, "clientPlayer is not null");
|
|
|
|
yield return NetcodeIntegrationTestHelpers.WaitForTicks(m_ServerNetworkManager, 3);
|
|
|
|
// server rigidbody has authority and should not be kinematic
|
|
Assert.True(serverPlayer.GetComponent<Rigidbody>().isKinematic == false, "serverPlayer kinematic");
|
|
Assert.AreEqual(RigidbodyInterpolation.Interpolate, serverPlayer.GetComponent<Rigidbody>().interpolation, "server equal interpolate");
|
|
|
|
// client rigidbody has no authority and should have a kinematic mode of true
|
|
Assert.True(clientPlayer.GetComponent<Rigidbody>().isKinematic, "clientPlayer kinematic");
|
|
Assert.AreEqual(RigidbodyInterpolation.None, clientPlayer.GetComponent<Rigidbody>().interpolation, "client equal interpolate");
|
|
|
|
// despawn the server player (but keep it around on the server)
|
|
serverPlayer.GetComponent<NetworkObject>().Despawn(false);
|
|
|
|
yield return NetcodeIntegrationTestHelpers.WaitForTicks(m_ServerNetworkManager, 3);
|
|
|
|
// When despawned, we should always be kinematic (i.e. don't apply physics when despawned)
|
|
Assert.IsTrue(serverPlayer.GetComponent<Rigidbody>().isKinematic == true, "serverPlayer second kinematic");
|
|
|
|
yield return NetcodeIntegrationTestHelpers.WaitForTicks(m_ServerNetworkManager, 3);
|
|
|
|
Assert.IsTrue(clientPlayer == null, "clientPlayer being null"); // safety check that object is actually despawned.
|
|
}
|
|
}
|
|
}
|
|
#endif // COM_UNITY_MODULES_PHYSICS
|