Interpolation

Overview

Depending on the settings in our project, data may not always arrive at a smooth 60 frames per second through the network. This is completely okay, but in order to make state changes (e.g. movement, rotation) appear smooth on the client, we use interpolation.

Interpolation is a type of estimation, a method of constructing new data points within the range of a discrete set of known data points.

The way interpolation works in coherence is that we wait for three data points and then start smoothing the subsequent values according to the interpolation parameters defined in the interpolation settings provided.

Binding Interpolation Settings

On the Select and Optimize windows, every binding which has an interpolable type will shows a interpolation settings object picker next to it.

Currently supported interpolable types are:

  • int

  • float

  • Vector2

  • Vector3

  • Quaternion

coherence provides built-in interpolation settings for position and rotation, but you are free to create your own and use them instead.

You can also create an interpolation settings asset: Assets > Create > coherence > Interpolation Settings

There, you have a few settings you can tweak:

  • Curve Type: the type of interpolation used

  • Elasticity: seconds to remain behind the current interpolation point, applied to smoothdamp function or slerp

  • Max Distance: maximum distance between data points before the component "teleports" to the next value without smoothing.

  • Latency

    • Manual: seconds to stay behind the sample data.

    • Auto: targetInterpolation = autoLatencyFactor * packetDeltaTime

      • -1 disables auto latency.

  • Overshooting

    • Max: how far into dead reckoning we can venture when the time fraction exceeds 100%.

    • Retraction: how fast to pull back to 100% if we overshoot the allowed dead reckoning maximum in seconds

Interpolation works both in baked and reflection modes. You can change these settings at runtime via the Select window (editor) or accessing the binding and changing the interpolation settings yourself:

if (coherenceSync.TryGetBinding(typeof(Transform), "position", out IBinding binding)
{
    // change your interpolation settings at runtime
    binding.InterpolationSettings = ...
}

Last updated