docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class PositionPredictor

    This is a utility class to implement position predicting.

    Inheritance
    object
    PositionPredictor
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Cinemachine.Utility
    Assembly: Cinemachine.dll
    Syntax
    public class PositionPredictor

    Fields

    Smoothing

    How much to smooth the predicted result. Must be >= 0, roughly coresponds to smoothing time.

    Declaration
    public float Smoothing
    Field Value
    Type Description
    float

    Methods

    AddPosition(Vector3, float, float)

    Add a new target position to the history buffer

    Declaration
    public void AddPosition(Vector3 pos, float deltaTime, float lookaheadTime)
    Parameters
    Type Name Description
    Vector3 pos

    The new target position

    float deltaTime

    deltaTime since the last target position was added

    float lookaheadTime

    Current lookahead time setting (unused)

    ApplyTransformDelta(Vector3)

    Apply a delta to the target's position, which will be ignored for smoothing purposes. Use this whent he target's position gets warped.

    Declaration
    public void ApplyTransformDelta(Vector3 positionDelta)
    Parameters
    Type Name Description
    Vector3 positionDelta

    The position change of the target object

    IsEmpty()

    Have any positions been logged for smoothing?

    Declaration
    public bool IsEmpty()
    Returns
    Type Description
    bool

    True if no positions have yet been logged, in which case smoothing is impossible

    PredictPosition(float)

    Predict the target's position a given time from now

    Declaration
    public Vector3 PredictPosition(float lookaheadTime)
    Parameters
    Type Name Description
    float lookaheadTime

    How far ahead in time to predict

    Returns
    Type Description
    Vector3

    The predicted position

    PredictPositionDelta(float)

    Predict the target's position change over a given time from now

    Declaration
    public Vector3 PredictPositionDelta(float lookaheadTime)
    Parameters
    Type Name Description
    float lookaheadTime

    How far ahead in time to predict

    Returns
    Type Description
    Vector3

    The predicted position change (current velocity * lokahead time)

    Reset()

    Reset the lookahead data, clear all the buffers.

    Declaration
    public void Reset()
    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)