docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class NetworkTransformPacketLossTests

    Integration tests for NetworkTransform that will test both server and host operating modes and will test both authoritative models for each operating mode when packet loss and latency is present.

    Inheritance
    object
    NetcodeIntegrationTest
    IntegrationTestWithApproximation
    NetworkTransformBase
    NetworkTransformPacketLossTests
    Inherited Members
    NetworkTransformBase.k_PositionRotationScaleIterations
    NetworkTransformBase.k_PositionRotationScaleIterations3Axis
    NetworkTransformBase.m_CurrentHalfPrecision
    NetworkTransformBase.k_HalfPrecisionPosScale
    NetworkTransformBase.k_HalfPrecisionRot
    NetworkTransformBase.m_AuthoritativePlayer
    NetworkTransformBase.m_NonAuthoritativePlayer
    NetworkTransformBase.m_ChildObject
    NetworkTransformBase.m_SubChildObject
    NetworkTransformBase.m_ParentObject
    NetworkTransformBase.m_AuthoritativeTransform
    NetworkTransformBase.m_NonAuthoritativeTransform
    NetworkTransformBase.m_OwnerTransform
    NetworkTransformBase.m_OriginalTargetFrameRate
    NetworkTransformBase.m_CurrentAxis
    NetworkTransformBase.m_AxisExcluded
    NetworkTransformBase.m_DetectedPotentialInterpolatedTeleport
    NetworkTransformBase.m_InfoMessage
    NetworkTransformBase.m_Rotation
    NetworkTransformBase.m_Precision
    NetworkTransformBase.m_RotationCompression
    NetworkTransformBase.m_Authority
    NetworkTransformBase.m_ChildObjectLocalPosition
    NetworkTransformBase.m_ChildObjectLocalRotation
    NetworkTransformBase.m_ChildObjectLocalScale
    NetworkTransformBase.m_SubChildObjectLocalPosition
    NetworkTransformBase.m_SubChildObjectLocalRotation
    NetworkTransformBase.m_SubChildObjectLocalScale
    NetworkTransformBase.m_AuthorityParentObject
    NetworkTransformBase.m_AuthorityParentNetworkTransform
    NetworkTransformBase.m_AuthorityChildObject
    NetworkTransformBase.m_AuthoritySubChildObject
    NetworkTransformBase.m_AuthorityChildNetworkTransform
    NetworkTransformBase.m_AuthoritySubChildNetworkTransform
    NetworkTransformBase.NumberOfClients
    NetworkTransformBase.GetDeltaVarianceThreshold()
    NetworkTransformBase.OnNumberOfClients()
    NetworkTransformBase.UseUnreliableDeltas()
    NetworkTransformBase.Setup()
    NetworkTransformBase.Teardown()
    NetworkTransformBase.OnInlineSetup()
    NetworkTransformBase.OnInlineTearDown()
    NetworkTransformBase.OnSetup()
    NetworkTransformBase.OnTearDown()
    NetworkTransformBase.TargetFrameRate()
    NetworkTransformBase.OnOneTimeSetup()
    NetworkTransformBase.OnOneTimeTearDown()
    NetworkTransformBase.OnCreatePlayerPrefab()
    NetworkTransformBase.OnServerAndClientsCreated()
    NetworkTransformBase.OnClientsAndServerConnectedSetup()
    NetworkTransformBase.OnServerAndClientsConnected()
    NetworkTransformBase.OnNewClientCreated(NetworkManager)
    NetworkTransformBase.AllChildObjectInstancesAreSpawned()
    NetworkTransformBase.AllChildObjectInstancesHaveChild()
    NetworkTransformBase.AllInstancesKeptLocalTransformValues(bool)
    NetworkTransformBase.PostAllChildrenLocalTransformValuesMatch(bool)
    NetworkTransformBase.MoveRotateAndScaleAuthority(Vector3, Vector3, Vector3, NetworkTransformBase.OverrideState)
    NetworkTransformBase.RandomlyExcludeAxis(Vector3)
    NetworkTransformBase.PositionRotationScaleMatches()
    NetworkTransformBase.PositionRotationScaleMatches(Vector3, Vector3, Vector3)
    NetworkTransformBase.PositionsMatchesValue(Vector3)
    NetworkTransformBase.RotationMatchesValue(Vector3)
    NetworkTransformBase.ScaleMatchesValue(Vector3)
    NetworkTransformBase.TeleportPositionMatches(Vector3)
    NetworkTransformBase.RotationsMatch(bool)
    NetworkTransformBase.PositionsMatch(bool)
    NetworkTransformBase.ScaleValuesMatch(bool)
    IntegrationTestWithApproximation.EulerDelta(float, float)
    IntegrationTestWithApproximation.EulerDelta(Vector3, Vector3)
    IntegrationTestWithApproximation.ApproximatelyEuler(float, float)
    IntegrationTestWithApproximation.Approximately(float, float)
    IntegrationTestWithApproximation.Approximately(Vector2, Vector2)
    IntegrationTestWithApproximation.Approximately(Vector3, Vector3)
    IntegrationTestWithApproximation.Approximately(Quaternion, Quaternion)
    IntegrationTestWithApproximation.ApproximatelyEuler(Vector3, Vector3)
    IntegrationTestWithApproximation.GetRandomVector3(float, float)
    NetcodeIntegrationTest.s_GlobalTimeoutHelper
    NetcodeIntegrationTest.s_DefaultWaitForTick
    NetcodeIntegrationTest.NetcodeLogAssert
    NetcodeIntegrationTest.s_GlobalNetworkObjects
    NetcodeIntegrationTest.RegisterNetworkObject(NetworkObject)
    NetcodeIntegrationTest.DeregisterNetworkObject(NetworkObject)
    NetcodeIntegrationTest.DeregisterNetworkObject(ulong, ulong)
    NetcodeIntegrationTest.TotalClients
    NetcodeIntegrationTest.k_DefaultTickRate
    NetcodeIntegrationTest.m_CreateServerFirst
    NetcodeIntegrationTest.m_PlayerPrefab
    NetcodeIntegrationTest.m_ServerNetworkManager
    NetcodeIntegrationTest.m_ClientNetworkManagers
    NetcodeIntegrationTest.m_PlayerNetworkObjects
    NetcodeIntegrationTest.m_UseHost
    NetcodeIntegrationTest.m_TargetFrameRate
    NetcodeIntegrationTest.m_EnableVerboseDebug
    NetcodeIntegrationTest.m_BypassConnectionTimeout
    NetcodeIntegrationTest.VerboseDebug(string)
    NetcodeIntegrationTest.OnSetVerboseDebug()
    NetcodeIntegrationTest.OnSetIntegrationTestMode()
    NetcodeIntegrationTest.OneTimeSetup()
    NetcodeIntegrationTest.SetUp()
    NetcodeIntegrationTest.OnPlayerPrefabGameObjectCreated()
    NetcodeIntegrationTest.CreateServerAndClients()
    NetcodeIntegrationTest.OnNewClientStarted(NetworkManager)
    NetcodeIntegrationTest.OnNewClientStartedAndConnected(NetworkManager)
    NetcodeIntegrationTest.ShouldWaitForNewClientToConnect(NetworkManager)
    NetcodeIntegrationTest.CreateAndStartNewClient()
    NetcodeIntegrationTest.CreateAndStartNewClientWithTimeTravel()
    NetcodeIntegrationTest.StopOneClient(NetworkManager, bool)
    NetcodeIntegrationTest.StopOneClientWithTimeTravel(NetworkManager, bool)
    NetcodeIntegrationTest.SetTimeTravelSimulatedLatency(float)
    NetcodeIntegrationTest.SetTimeTravelSimulatedDropRate(float)
    NetcodeIntegrationTest.SetTimeTravelSimulatedLatencyJitter(float)
    NetcodeIntegrationTest.CreateServerAndClients(int)
    NetcodeIntegrationTest.CanStartServerAndClients()
    NetcodeIntegrationTest.OnStartedServerAndClients()
    NetcodeIntegrationTest.OnTimeTravelStartedServerAndClients()
    NetcodeIntegrationTest.ClientNetworkManagerPostStartInit()
    NetcodeIntegrationTest.LogAllMessages
    NetcodeIntegrationTest.StartServerAndClients()
    NetcodeIntegrationTest.StartServerAndClientsWithTimeTravel()
    NetcodeIntegrationTest.CanClientsLoad()
    NetcodeIntegrationTest.CanClientsUnload()
    NetcodeIntegrationTest.DeRegisterSceneManagerHandler()
    NetcodeIntegrationTest.RegisterSceneManagerHandler()
    NetcodeIntegrationTest.OnCanSceneCleanUpUnload(Scene)
    NetcodeIntegrationTest.ShutdownAndCleanUp()
    NetcodeIntegrationTest.TearDown()
    NetcodeIntegrationTest.OneTimeTearDown()
    NetcodeIntegrationTest.CanDestroyNetworkObject(NetworkObject)
    NetcodeIntegrationTest.DestroySceneNetworkObjects()
    NetcodeIntegrationTest.EnableMessageLogging()
    NetcodeIntegrationTest.WaitForConditionOrTimeOut(Func<bool>, TimeoutHelper)
    NetcodeIntegrationTest.WaitForConditionOrTimeOutWithTimeTravel(Func<bool>, int)
    NetcodeIntegrationTest.WaitForConditionOrTimeOut(IConditionalPredicate, TimeoutHelper)
    NetcodeIntegrationTest.WaitForConditionOrTimeOutWithTimeTravel(IConditionalPredicate, int)
    NetcodeIntegrationTest.WaitForClientsConnectedOrTimeOut(NetworkManager[])
    NetcodeIntegrationTest.WaitForClientsConnectedOrTimeOutWithTimeTravel(NetworkManager[])
    NetcodeIntegrationTest.WaitForClientsConnectedOrTimeOut()
    NetcodeIntegrationTest.WaitForClientsConnectedOrTimeOutWithTimeTravel()
    NetcodeIntegrationTest.CreateNetworkObjectPrefab(string)
    NetcodeIntegrationTest.SpawnObject(GameObject, NetworkManager, bool)
    NetcodeIntegrationTest.SpawnObjects(GameObject, NetworkManager, int, bool)
    NetcodeIntegrationTest.AssertOnTimeout(string, TimeoutHelper)
    NetcodeIntegrationTest.WaitForTicks(NetworkManager, int)
    NetcodeIntegrationTest.TimeTravel(double, int)
    NetcodeIntegrationTest.GetTickRate()
    NetcodeIntegrationTest.GetFrameRate()
    NetcodeIntegrationTest.ConfigureFramesPerTick()
    NetcodeIntegrationTest.TimeTravelAdvanceTick()
    NetcodeIntegrationTest.TimeTravelToNextTick()
    NetcodeIntegrationTest.SimulateOneFrame()
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.Netcode.RuntimeTests
    Assembly: Unity.Netcode.RuntimeTests.dll
    Syntax
    [TestFixture(new object[] { NetcodeIntegrationTest.HostOrServer.Host, NetworkTransformBase.Authority.ServerAuthority, NetworkTransformBase.RotationCompression.None, NetworkTransformBase.Rotation.Euler, NetworkTransformBase.Precision.Full })]
    [TestFixture(new object[] { NetcodeIntegrationTest.HostOrServer.Host, NetworkTransformBase.Authority.ServerAuthority, NetworkTransformBase.RotationCompression.None, NetworkTransformBase.Rotation.Euler, NetworkTransformBase.Precision.Half })]
    [TestFixture(new object[] { NetcodeIntegrationTest.HostOrServer.Host, NetworkTransformBase.Authority.ServerAuthority, NetworkTransformBase.RotationCompression.None, NetworkTransformBase.Rotation.Quaternion, NetworkTransformBase.Precision.Full })]
    [TestFixture(new object[] { NetcodeIntegrationTest.HostOrServer.Host, NetworkTransformBase.Authority.ServerAuthority, NetworkTransformBase.RotationCompression.None, NetworkTransformBase.Rotation.Quaternion, NetworkTransformBase.Precision.Half })]
    [TestFixture(new object[] { NetcodeIntegrationTest.HostOrServer.Host, NetworkTransformBase.Authority.ServerAuthority, NetworkTransformBase.RotationCompression.QuaternionCompress, NetworkTransformBase.Rotation.Quaternion, NetworkTransformBase.Precision.Full })]
    [TestFixture(new object[] { NetcodeIntegrationTest.HostOrServer.Host, NetworkTransformBase.Authority.ServerAuthority, NetworkTransformBase.RotationCompression.QuaternionCompress, NetworkTransformBase.Rotation.Quaternion, NetworkTransformBase.Precision.Half })]
    public class NetworkTransformPacketLossTests : NetworkTransformBase

    Constructors

    NetworkTransformPacketLossTests(HostOrServer, Authority, RotationCompression, Rotation, Precision)

    Constructor

    Declaration
    public NetworkTransformPacketLossTests(NetcodeIntegrationTest.HostOrServer testWithHost, NetworkTransformBase.Authority authority, NetworkTransformBase.RotationCompression rotationCompression, NetworkTransformBase.Rotation rotation, NetworkTransformBase.Precision precision)
    Parameters
    Type Name Description
    NetcodeIntegrationTest.HostOrServer testWithHost

    Determines if we are running as a server or host

    NetworkTransformBase.Authority authority

    Determines if we are using server or owner authority

    NetworkTransformBase.RotationCompression rotationCompression
    NetworkTransformBase.Rotation rotation
    NetworkTransformBase.Precision precision

    Properties

    m_EnableTimeTravel

    Enables "Time Travel" within the test, which swaps the time provider for the SDK from Unity's Time class to MockTimeProvider, and also swaps the transport implementation from UnityTransport to MockTransport.

    This enables five important things that help with both performance and determinism of tests that involve a lot of time and waiting:

    1. It allows time to move in a completely deterministic way (testing that something happens after n seconds, the test will always move exactly n seconds with no chance of any variability in the timing),
    2. It allows skipping periods of time without actually waiting that amount of time, while still simulating SDK frames as if that time were passing,
    3. It dissociates the SDK's update loop from Unity's update loop, allowing us to simulate SDK frame updates without waiting for Unity to process things like physics, animation, and rendering that aren't relevant to the test,
    4. It dissociates the SDK's messaging system from the networking hardware, meaning there's no delay between a message being sent and it being received, allowing us to deterministically rely on the message being received within specific time frames for the test, and
    5. It allows tests to be written without the use of coroutines, which not only improves the test's runtime, but also results in easier-to-read callstacks and removes the possibility for an assertion to result in the test hanging.

    When time travel is enabled, the following methods become available:

    TimeTravel(double, int): Simulates a specific number of frames passing over a specific time period TimeTravelToNextTick(): Skips forward to the next tick, siumlating at the current application frame rate WaitForConditionOrTimeOutWithTimeTravel(Func<bool>, int): Simulates frames at the application frame rate until the given condition is true WaitForMessageReceivedWithTimeTravel<T>(List<NetworkManager>, ReceiptType): Simulates frames at the application frame rate until the required message is received WaitForMessagesReceivedWithTimeTravel(List<Type>, List<NetworkManager>, ReceiptType): Simulates frames at the application frame rate until the required messages are received StartServerAndClientsWithTimeTravel(): Starts a server and client and allows them to connect via simulated frames CreateAndStartNewClientWithTimeTravel(): Creates a client and waits for it to connect via simulated frames WaitForClientsConnectedOrTimeOutWithTimeTravel(NetworkManager[]) Simulates frames at the application frame rate until the given clients are connected StopOneClientWithTimeTravel(NetworkManager, bool): Stops a client and simulates frames until it's fully disconnected.

    When time travel is enabled, NetcodeIntegrationTest will automatically use these in its methods when doing things like automatically connecting clients during SetUp.

    Additionally, the following methods replace their non-time-travel equivalents with variants that are not coroutines: OnTimeTravelStartedServerAndClients() - called when server and clients are started OnTimeTravelServerAndClientsConnected() - called when server and clients are connected

    Note that all of the non-time travel functions can still be used even when time travel is enabled - this is sometimes needed for, e.g., testing NetworkAnimator, where the unity update loop needs to run to process animations. However, it's VERY important to note here that, because the SDK will not be operating based on real-world time but based on the frozen time that's locked in from MockTimeProvider, actions that pass 10 seconds apart by real-world clock time will be perceived by the SDK as having happened simultaneously if you don't call TimeTravel(double) to cover the equivalent time span in the mock time provider. (Calling TimeTravel(double) instead of TimeTravel(double, int) will move time forward without simulating any frames, which, in the case where real-world time has passed, is likely more desirable). In most cases, this desynch won't affect anything, but it is worth noting that it happens just in case a tested system depends on both the unity update loop happening and time moving forward.

    Declaration
    protected override bool m_EnableTimeTravel { get; }
    Property Value
    Type Description
    bool
    Overrides
    NetcodeIntegrationTest.m_EnableTimeTravel

    m_SetupIsACoroutine

    If this is false, SetUp will call OnInlineSetUp instead of OnSetUp. This is a performance advantage when not using the coroutine functionality, as a coroutine that has no yield instructions in it will nonetheless still result in delaying the continuation of the method that called it for a full frame after it returns.

    Declaration
    protected override bool m_SetupIsACoroutine { get; }
    Property Value
    Type Description
    bool
    Overrides
    NetcodeIntegrationTest.m_SetupIsACoroutine

    m_TearDownIsACoroutine

    If this is false, TearDown will call OnInlineTearDown instead of OnTearDown. This is a performance advantage when not using the coroutine functionality, as a coroutine that has no yield instructions in it will nonetheless still result in delaying the continuation of the method that called it for a full frame after it returns.

    Declaration
    protected override bool m_TearDownIsACoroutine { get; }
    Property Value
    Type Description
    bool
    Overrides
    NetcodeIntegrationTest.m_TearDownIsACoroutine

    Methods

    NetworkTransformMultipleChangesOverTime(TransformSpace, Axis)

    Declaration
    [Test]
    public void NetworkTransformMultipleChangesOverTime(NetworkTransformBase.TransformSpace testLocalTransform, NetworkTransformBase.Axis axis)
    Parameters
    Type Name Description
    NetworkTransformBase.TransformSpace testLocalTransform
    NetworkTransformBase.Axis axis

    OnTimeTravelServerAndClientsConnected()

    Invoked after the server and clients have started and verified their connections with each other.

    Declaration
    protected override void OnTimeTravelServerAndClientsConnected()
    Overrides
    NetworkTransformBase.OnTimeTravelServerAndClientsConnected()

    ParentedNetworkTransformTest(Interpolation, bool, float)

    Validates that transform values remain the same when a NetworkTransform is parented under another NetworkTransform under all of the possible axial conditions as well as when the parent has a varying scale.

    Declaration
    [Test]
    public void ParentedNetworkTransformTest(NetworkTransformBase.Interpolation interpolation, bool worldPositionStays, float scale)
    Parameters
    Type Name Description
    NetworkTransformBase.Interpolation interpolation
    bool worldPositionStays
    float scale

    TestAuthoritativeTransformChangeOneAtATime(TransformSpace, Interpolation)

    Tests changing all axial values one at a time with packet loss These tests are performed:

    • While in local space and world space
    • While interpolation is enabled and disabled
    Declaration
    [Test]
    public void TestAuthoritativeTransformChangeOneAtATime(NetworkTransformBase.TransformSpace testLocalTransform, NetworkTransformBase.Interpolation interpolation)
    Parameters
    Type Name Description
    NetworkTransformBase.TransformSpace testLocalTransform
    NetworkTransformBase.Interpolation interpolation

    TestSameFrameDeltaStateAndTeleport(TransformSpace, Interpolation)

    Declaration
    [Test]
    public void TestSameFrameDeltaStateAndTeleport(NetworkTransformBase.TransformSpace testLocalTransform, NetworkTransformBase.Interpolation interpolation)
    Parameters
    Type Name Description
    NetworkTransformBase.TransformSpace testLocalTransform
    NetworkTransformBase.Interpolation interpolation
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)