SyncFlags.Interpolate: How Networked Property Interpolation Works — Supported Types, InterpolationBuffer, and Delay
SyncFlags.Interpolate: How Networked Property Interpolation Works
When [Sync( SyncFlags.Interpolate )] is applied to a property, proxy clients receive a smoothed value between network ticks rather than the raw snapped value.
Supported Types
Interpolation is only supported for these types:
Any other type with SyncFlags.Interpolate will silently fall back to non-interpolated behavior.
How It Works
On proxy clients, the getter is wrapped by _syncGetValue. When SyncFlags.Interpolate is set:
- An InterpolatedSyncVar<T> is created on first use, backed by an InterpolationBuffer<T>.
- When a network update arrives, Update(value) adds the new value to the buffer with the current Time.NowDouble timestamp.
- The getter queries the buffer at Time.NowDouble - Networking.InterpolationTime, returning a smoothed value.
- Old buffer entries are culled when they are older than Networking.InterpolationTime 3.
public class MyComponent : Component
{
// Smooth position on proxies
[Sync( SyncFlags.Interpolate )] public Vector3 NetworkPosition { get; set; }
// Smooth rotation on proxies
[Sync( SyncFlags.Interpolate )] public Rotation NetworkRotation { get; set; }
protected override void OnUpdate()
{
if ( IsProxy )
{
// NetworkPosition returns interpolated value on proxies
WorldPosition = NetworkPosition;
}
}
}Interpolation Delay
The interpolation introduces a delay of Networking.InterpolationTime seconds. This is a trade-off: smoother movement at the cost of slightly delayed position display.
Owner Behavior
On the owner, SyncFlags.Interpolate has no effect on the getter — it returns the raw value directly. Interpolation only applies on proxy clients.
Transform Interpolation vs SyncFlags.Interpolate
The GameObject transform has its own built-in interpolation system (controlled by NetworkFlags.NoInterpolation). SyncFlags.Interpolate is for custom [Sync] properties, not the transform.