Table of Contents

BindingInterpolator<T>

BindingInterpolator is used to smoothly interpolate between samples received over the network. The following types are supported for interpolation: float, bool, int, long, Vector2, Vector3, Quaternion, Color, string and EntityReferences. Additional Smoothing (using SmoothDamp) is supported for types: float, Vector2, Vector3 and Quaternion.

Type Parameters

T
Constructors
BindingInterpolator(InterpolationSettings, double)
Fields
Settings

Interpolation settings which specify behaviour and type of the interpolator.

Time

The current time for this binding. It will trail behind NetworkTime by Delay seconds in order to produce smooth movement.

Properties
Buffer
Delay

The current internal latency for this binding, i.e., how many seconds this binding's Time trails behind NetworkTime.Time. Delay is lerped towards TargetDelay.

IsInterpolationNone

Returns true if the settings is the "None" interpolation mode.

IsStopped

When we are completely done with interpolation and there is nothing else to interpolate over, interpolation is marked as stopped. In other words, when we completely interpolated (t = 1) to the latest received sample (which must be stopped!), IsStopped is set true, and reset to false when we receive another sample.

MeasuredSampleDuration

The duration between samples at which samples are actually generated and transmitted from the entity owner. This is measured from incoming samples by finding the longest duration between samples in the current SampleBuffer<T>.

NetworkLatency

Latency between this client and the authority client that owns this entity, in seconds. This value is updated when new samples arrives so that Delay stays tuned to current network conditions. Network latency is scaled with networkLatencyFactor.

SampleRate

The frequency at which samples are generated and transmitted from the entity owner. Higher sample rates incur lower Delay. Value is automatically initialize by the corresponding Binding. Use the Optimize window to configure the sample rate for a binding.

TargetDelay

The target internal latency for this binding, i.e., how many seconds this binding's Time trails behind NetworkTime.Time. TargetDelay is computed from a number of factors, including sampling frequency, network latency and blending method.

Methods
AppendSample(T, bool, AbsoluteSimulationFrame, AbsoluteSimulationFrame)

Adds a sample to the sample buffer at the given frame.

AppendSample(T, bool, bool, double, double)

Adds a sample to the sample buffer at the given time.

CalculateInterpolationPercentage(double)
GetLastSample()

Return the last sample in the sample buffer, casted to the given type.

GetValueAt(double)

Queries the sample buffer for samples adjacent to the given time and performs blending between those samples using the interpolator.

IsBeyondTeleportDistance(int, int)
IsBeyondTeleportDistance(float, float)
IsBeyondTeleportDistance(Quaternion, Quaternion)
IsBeyondTeleportDistance(Vector2, Vector2)
IsBeyondTeleportDistance(Vector3, Vector3)
PerformInterpolation(T, double)

Performs interpolation on the given binding and returns its new value. Increments Time for this binding, taking Delay into account. Calculates the interpolated value for the latency-adjusted time using the interpolator. Applies additional Coherence.Interpolation.BindingInterpolator`1.smoothing for types that support it (float, double, Vector2, Vector3, Quaternion). If the sample buffer is empty, the currentValue will be returned. If the sample buffer contains a single sample, that sample value is returned with no blending or smoothing performed.

RemoveOutdatedSamples(double)

Removes outdated samples from the samples buffer. A sample is considered outdated if its timestamp is equal to or older than the given time. The number of samples left guarantees that both interpolation and extrapolation can happen.

Reset()

Resets the buffer and state variables. This is useful, e.g. when teleporting and re-parenting.