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
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
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 |
---|---|
float |
m_Buffer
Declaration
protected readonly List<BufferedLinearInterpolator<T>.BufferedItem> m_Buffer
Field Value
Type | Description |
---|---|
List<BufferedLinearInterpolator<T>.BufferedItem> |
m_CurrentInterpValue
Declaration
protected T m_CurrentInterpValue
Field Value
Type | Description |
---|---|
T |
m_InterpEndValue
Declaration
protected T m_InterpEndValue
Field Value
Type | Description |
---|---|
T |
m_InterpStartValue
Declaration
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 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, 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, bool)
Declaration
protected virtual void OnConvertTransformSpace(Transform transform, bool inLocalSpace)
Parameters
Type | Name | Description |
---|---|---|
Transform | transform | |
bool | inLocalSpace |
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(float, 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 |
---|---|---|
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' |
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
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' |