Class BufferedLinearInterpolator<T>
Solves for incoming values that are jittered Partially solves for message loss. Unclamped lerping helps hide this, but not completely
Inherited Members
Namespace: Unity.Netcode
Syntax
public abstract class BufferedLinearInterpolator<T>
where T : struct
Type Parameters
Name | Description |
---|---|
T | The type of interpolated value |
Fields
MaximumInterpolationTime
There's two factors affecting interpolation: buffering (set in NetworkManager's NetworkTimeSystem) and interpolation time, which is the amount of time it'll take to reach the target. This is to affect the second one.
Declaration
public float MaximumInterpolationTime
Field Value
Type | Description |
---|---|
Single |
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 initial state
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, Single)
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) |
Single | time | The time value used to interpolate between start and end values (pos) |
Returns
Type | Description |
---|---|
T | The interpolated value |
InterpolateUnclamped(T, T, Single)
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) |
Single | time | The time value used to interpolate between start and end values (pos) |
Returns
Type | Description |
---|---|
T | The interpolated value |
ResetTo(T, Double)
Teleports current interpolation value to targetValue.
Declaration
public void ResetTo(T targetValue, double serverTime)
Parameters
Type | Name | Description |
---|---|---|
T | targetValue | The target value to teleport instantly |
Double | serverTime | The current server time |
Update(Single, Double, Double)
Call to update the state of the interpolators before reading out
Declaration
public T Update(float deltaTime, double renderTime, double serverTime)
Parameters
Type | Name | Description |
---|---|---|
Single | 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' |
Update(Single, 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
public T Update(float deltaTime, NetworkTime serverTime)
Parameters
Type | Name | Description |
---|---|---|
Single | deltaTime | time since call |
NetworkTime | serverTime | current server time |
Returns
Type | Description |
---|---|
T | The newly interpolated value of type 'T' |