docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct PhysicsWorldHistorySingleton

    A singleton component from which you can get a physics collision world for a previous tick.

    Implements
    IComponentData
    IQueryTypeParameter
    Inherited Members
    ValueType.Equals(object)
    ValueType.GetHashCode()
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: Unity.NetCode
    Assembly: Unity.NetCode.Physics.dll
    Syntax
    public struct PhysicsWorldHistorySingleton : IComponentData, IQueryTypeParameter

    Fields

    DeepCopyRigidBodyCollidersWhitelist

    An optional collection specifying a manual whitelist of Unity.Physics.CollisionWorld.Bodies indexes that you want to opt-into deep copying the collider blob assets of (each specified by its Unity.Physics.CollisionWorld.GetRigidBodyIndex(Unity.Entities.Entity) index).
    Must not contain duplicate entries, and must not contain indices of rigid bodies whose colliders will already be deep copied due to the values chosen for the DeepCopyDynamicColliders and DeepCopyStaticColliders parameters.

    Declaration
    [NativeDisableContainerSafetyRestriction]
    public NativeList<int> DeepCopyRigidBodyCollidersWhitelist
    Field Value
    Type Description
    NativeList<int>
    Remarks

    If you know exactly which set of ghosts you need lag compensation for, it may be simpler to pass their indexes here. Use Unity.Physics.CollisionWorld.GetRigidBodyIndex(Unity.Entities.Entity) to map an entity to a rigidbody.

    Properties

    LatestStoredTick

    Returns the latest (i.e. newest) tick stored into the CollisionHistoryBuffer.

    Declaration
    public NetworkTick LatestStoredTick { get; }
    Property Value
    Type Description
    NetworkTick

    Methods

    GetCollisionWorldFromTick(NetworkTick, uint, ref PhysicsWorld, out CollisionWorld)

    Get the Unity.Physics.CollisionWorld state for the given tick and interpolation delay.

    Declaration
    public void GetCollisionWorldFromTick(NetworkTick tick, uint interpolationDelay, ref PhysicsWorld physicsWorld, out CollisionWorld collWorld)
    Parameters
    Type Name Description
    NetworkTick tick

    The server tick we are simulating.

    uint interpolationDelay

    The client interpolation delay, measured in ticks. This is used to look back in time and retrieve the state of the collision world at tick - interpolationDelay. The interpolation delay is internally clamped to the current collision history size (the number of saved history state).

    PhysicsWorld physicsWorld

    The physics world which is use to get collision worlds for ticks which are not yet in the history buffer.

    CollisionWorld collWorld

    The Unity.Physics.CollisionWorld state retrieved from the history.

    GetCollisionWorldFromTick(NetworkTick, uint, ref PhysicsWorld, out CollisionWorld, out NetworkTick, out NetworkTick)

    Get the Unity.Physics.CollisionWorld state for the given tick and interpolation delay.

    Declaration
    public void GetCollisionWorldFromTick(NetworkTick tick, uint interpolationDelay, ref PhysicsWorld physicsWorld, out CollisionWorld collWorld, out NetworkTick expectedTick, out NetworkTick returnedTick)
    Parameters
    Type Name Description
    NetworkTick tick

    The server tick we are simulating.

    uint interpolationDelay

    The client interpolation delay, measured in ticks. This is used to look back in time and retrieve the state of the collision world at tick - interpolationDelay. The interpolation delay is internally clamped to the current collision history size (the number of saved history state).

    PhysicsWorld physicsWorld

    The physics world which is use to get collision worlds for ticks which are not yet in the history buffer.

    CollisionWorld collWorld

    The Unity.Physics.CollisionWorld state retrieved from the history.

    NetworkTick expectedTick

    The tick we should be fetching, after subtracting interpolationDelay.

    NetworkTick returnedTick

    The tick index we actually fetched, due to clamping. I.e. If clamped to the oldest stored tick, you'll see the eldest stored tick returned here.
    Compare this to the expectedTick to determine that a players interpolationDelay is so high that they're hitting the clamp.

    GetHistoryBufferData(ref PhysicsWorld)

    Helper to retrieve debug data from the history buffer.

    Declaration
    public string GetHistoryBufferData(ref PhysicsWorld physicsWorld)
    Parameters
    Type Name Description
    PhysicsWorld physicsWorld

    Physics world containing history buffer

    Returns
    Type Description
    string

    History buffer

    Implements

    Unity.Entities.IComponentData
    Unity.Entities.IQueryTypeParameter
    In This Article
    Back to top
    Copyright © 2025 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)