docs.unity.cn
    Show / Hide Table of Contents

    Struct PositionPredictor

    This is a utility to implement position predicting.

    Namespace: Unity.Cinemachine
    Syntax
    public struct PositionPredictor

    Fields

    Smoothing

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

    Declaration
    public float Smoothing
    Field Value
    Type Description
    Single

    Properties

    CurrentPosition

    Get the current position of the tracked object, as set by the last call to AddPosition(). This is only valid if IsEmpty returns false.

    Declaration
    public readonly Vector3 CurrentPosition { get; }
    Property Value
    Type Description
    Vector3

    The current position of the tracked object, as set by the last call to AddPosition()

    IsEmpty

    Have any positions been logged for smoothing?

    Declaration
    public readonly bool IsEmpty { get; }
    Property Value
    Type Description
    Boolean

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

    Methods

    AddPosition(Vector3, Single)

    Add a new target position to the history buffer

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

    The new target position

    Single deltaTime

    deltaTime since the last target position was added

    ApplyTransformDelta(Vector3)

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

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

    The position change of the target object

    PredictPositionDelta(Single)

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

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

    How far ahead in time to predict

    Returns
    Type Description
    Vector3

    The predicted position change (current velocity * lookahead time)

    Reset()

    Reset the lookahead data, clear all the buffers.

    Declaration
    public void Reset()
    Back to top Copyright © 2023 Unity Technologies — Terms of use
    Generated by DocFX
    on Saturday, May 6, 2023