Class PositionPredictor
This is a utility class to implement position predicting.
Namespace: Cinemachine.Utility
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 |
---|---|
Single |
Methods
AddPosition(Vector3, Single, Single)
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 |
Single | deltaTime | deltaTime since the last target position was added |
Single | 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 |
---|---|
Boolean | True if no positions have yet been logged, in which case smoothing is impossible |
PredictPosition(Single)
Predict the target's position a given time from now
Declaration
public Vector3 PredictPosition(float lookaheadTime)
Parameters
Type | Name | Description |
---|---|---|
Single | lookaheadTime | How far ahead in time to predict |
Returns
Type | Description |
---|---|
Vector3 | The predicted position |
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 * lokahead time) |
Reset()
Reset the lookahead data, clear all the buffers.
Declaration
public void Reset()