docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class BufferedLinearInterpolator<T>

    Solves for incoming values that are jittered. Partially solves for message loss. Unclamped lerping helps hide this, but not completely

    Inheritance
    object
    BufferedLinearInterpolator<T>
    BufferedLinearInterpolatorFloat
    BufferedLinearInterpolatorQuaternion
    BufferedLinearInterpolatorVector3
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.Netcode
    Assembly: Unity.Netcode.Runtime.dll
    Syntax
    public abstract class BufferedLinearInterpolator<T> where T : struct
    Type Parameters
    Name Description
    T

    The type of interpolated value

    Fields

    MaximumInterpolationTime

    Determines how much smoothing will be applied to the 2nd lerp when using the Update(float, double, double) (i.e. lerping and not smooth dampening).

    Declaration
    [Range(0.016, 1)]
    public float MaximumInterpolationTime
    Field Value
    Type Description
    float
    Remarks

    There's two factors affecting interpolation:

    • Buffering: Which can be adjusted in set in the NetworkTimeSystem.
    • Interpolation time: The divisor applied to delta time where the quotient is used as the lerp time.

    m_Buffer

    The legacy list of BufferedLinearInterpolator<T>.BufferedItem items.

    Declaration
    [Obsolete("This list is no longer used and will be deprecated.", false)]
    protected readonly List<BufferedLinearInterpolator<T>.BufferedItem> m_Buffer
    Field Value
    Type Description
    List<BufferedLinearInterpolator<T>.BufferedItem>
    Remarks

    This is replaced by the m_BufferQueue of type Queue<T>.

    m_BufferQueue

    The current buffered items received by the authority.

    Declaration
    protected readonly Queue<BufferedLinearInterpolator<T>.BufferedItem> m_BufferQueue
    Field Value
    Type Description
    Queue<BufferedLinearInterpolator<T>.BufferedItem>

    m_CurrentInterpValue

    ** Deprecating ** The current value of type T.

    Declaration
    [Obsolete("This property will be deprecated.", false)]
    protected T m_CurrentInterpValue
    Field Value
    Type Description
    T

    m_InterpEndValue

    ** Deprecating ** The end (or target) value of type T to interpolate towards.

    Declaration
    [Obsolete("This property will be deprecated.", false)]
    protected T m_InterpEndValue
    Field Value
    Type Description
    T

    m_InterpStartValue

    ** Deprecating ** The starting value of type T to interpolate from.

    Declaration
    [Obsolete("This property will be deprecated.", false)]
    protected T m_InterpStartValue
    Field Value
    Type Description
    T

    Methods

    AddMeasurement(T, double)

    Add measurements to be used during interpolation. These will be buffered before being made available to be displayed as "latest value".

    Declaration
    public void AddMeasurement(T newMeasurement, double sentTime)
    Parameters
    Type Name Description
    T newMeasurement

    The new measurement value to use

    double sentTime

    The time to record for measurement

    Clear()

    Resets interpolator to the defaults.

    Declaration
    public void Clear()

    GetInterpolatedValue()

    Gets latest value from the interpolator. This is updated every update as time goes by.

    Declaration
    public T GetInterpolatedValue()
    Returns
    Type Description
    T

    The current interpolated value of type 'T'

    Interpolate(T, T, float)

    Method to override and adapted to the generic type. This assumes interpolation for that value will be clamped.

    Declaration
    protected abstract T Interpolate(T start, T end, float time)
    Parameters
    Type Name Description
    T start

    The start value (min)

    T end

    The end value (max)

    float time

    The time value used to interpolate between start and end values (pos)

    Returns
    Type Description
    T

    The interpolated value

    InterpolateUnclamped(T, T, float)

    Method to override and adapted to the generic type. This assumes interpolation for that value will not be clamped.

    Declaration
    protected abstract T InterpolateUnclamped(T start, T end, float time)
    Parameters
    Type Name Description
    T start

    The start value (min)

    T end

    The end value (max)

    float time

    The time value used to interpolate between start and end values (pos)

    Returns
    Type Description
    T

    The interpolated value

    OnConvertTransformSpace(Transform, T, bool)

    Converts a value of type T from world to local space or vice versa.

    Declaration
    protected virtual T OnConvertTransformSpace(Transform transform, T item, bool inLocalSpace)
    Parameters
    Type Name Description
    Transform transform

    Reference transform.

    T item

    The item to convert.

    bool inLocalSpace

    local or world space (true or false).

    Returns
    Type Description
    T

    The converted value.

    ResetTo(T, double)

    Resets the current interpolator to the target value.

    Declaration
    public void ResetTo(T targetValue, double serverTime)
    Parameters
    Type Name Description
    T targetValue

    The target value to reset the interpolator to

    double serverTime

    The current server time

    Remarks

    This is used when first synchronizing/initializing and when telporting an object.

    Update(float, double, double)

    Call to update the state of the interpolators using Lerp.

    Declaration
    public T Update(float deltaTime, double renderTime, double serverTime)
    Parameters
    Type Name Description
    float deltaTime

    time since last call

    double renderTime

    our current time

    double serverTime

    current server time

    Returns
    Type Description
    T

    The newly interpolated value of type 'T'

    Remarks

    This approah uses double lerping which can result in an over-smoothed result.

    Update(float, NetworkTime)

    Convenience version of 'Update' mainly for testing the reason we don't want to always call this version is so that on the calling side we can compute the renderTime once for the many things being interpolated (and the many interpolators per object)

    Declaration
    [Obsolete("This method is being deprecated due to it being only used for internal testing purposes.", false)]
    public T Update(float deltaTime, NetworkTime serverTime)
    Parameters
    Type Name Description
    float deltaTime

    time since call

    NetworkTime serverTime

    current server time

    Returns
    Type Description
    T

    The newly interpolated value of type 'T'

    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)