Skip to content

fix: Lerp smoothing frame rate dependence and freeze at maximum interpolation - #4132

Open
NoelStephensUnity wants to merge 2 commits into
develop-3.x.xfrom
fix/interpolator-lerp-smoothing-framerate-up-port
Open

fix: Lerp smoothing frame rate dependence and freeze at maximum interpolation#4132
NoelStephensUnity wants to merge 2 commits into
develop-3.x.xfrom
fix/interpolator-lerp-smoothing-framerate-up-port

Conversation

@NoelStephensUnity

Copy link
Copy Markdown
Member

Purpose of this PR

This is an up-port of #4130
(see original PR for extended details)

Jira ticket

NA

Changelog

  • Fixed: Issue where lerp smoothing was applied per frame instead of over time, which caused the Lerp and SmoothDampening interpolation types to smooth by different amounts at different frame rates. Results at 60fps are unchanged.
  • Fixed: Issue where setting a maximum interpolation time of 1.0 would stop a NetworkTransform from interpolating at all when using the Lerp or SmoothDampening interpolation types.

Documentation

  • No documentation changes or additions were necessary.
  • Includes documentation for previously-undocumented public API entry points.
  • Includes edits to existing public API documentation.

Testing & QA (How your changes can be verified during release Playtest)

Functional Testing

Manual testing :

  • Manual testing done

Automated tests:

  • Covered by existing automated tests
  • Covered by new automated tests

Does the change require QA team to:

  • Review automated tests?
  • Execute manual tests?
  • Provide feedback about the PR?

Up-port

Not needed (this is an up-port).

Backports

Not needed.

…polation time

The lerp smoothing pass used by the Lerp and SmoothDampening interpolation
types applied a fixed factor of 1.0 minus the maximum interpolation time once
per frame, with no delta time. The wall clock smoothing rate therefore scaled
with the frame rate, so the same setting smoothed by different amounts on
different hardware. The factor is now raised to the number of 60fps reference
frames elapsed, which makes the rate a function of elapsed time. Results at
60fps are unchanged for every legal setting.

Separately, a maximum interpolation time of 1.0 (the upper bound of the
inspector range) produced a factor of exactly 0, so the interpolated value
never advanced and the transform stopped moving entirely on all three axes.
The retained portion is now clamped just below 1.0. This is an independent
defect, as raising 1.0 to any power is still 1.0.

The LegacyLerp path was already frame rate correct and is unchanged. The
documentation on the lerp smoothing fields described the LegacyLerp formula
for all interpolation types and has been corrected.
Adding PR number to change log entries.
@codecov-github-com

codecov-github-com Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

@@                Coverage Diff                @@
##           develop-3.x.x    #4132      +/-   ##
=================================================
+ Coverage          78.01%   78.03%   +0.01%     
=================================================
  Files                153      153              
  Lines              26254    26258       +4     
=================================================
+ Hits               20483    20490       +7     
+ Misses              5771     5768       -3     
Flag Coverage Δ
NGOv2_project_testproject_ubuntu_pinnedTrunk 77.73% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ponents/Interpolator/BufferedLinearInterpolator.cs 86.46% <100.00%> (+0.15%) ⬆️
...gameobjects/Runtime/Components/NetworkTransform.cs 88.42% <ø> (ø)

... and 1 file with indirect coverage changes

Components Coverage Δ
com.unity.netcode.gameobjects 78.03% <100.00%> (+0.01%) ⬆️

ℹ️ Need help interpreting these results?

@NoelStephensUnity
NoelStephensUnity requested a review from u-pr August 20, 2026 15:19

@u-pr u-pr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Harness Review

LGTM

The time-based smoothing implementation correctly preserves the 60 Hz behavior for the updated interpolation modes, but its public documentation now overstates the guarantee for the legacy path.

Reviewed commit 363c94d

🤖 Helpful? 👍/👎

/// When enabled, the <see cref="BufferedLinearInterpolator{T}"/> will apply a final lerping pass where the "t" parameter is calculated by dividing the frame time divided by the <see cref="PositionMaxInterpolationTime"/>.
/// When enabled, the <see cref="BufferedLinearInterpolator{T}"/> will apply a final lerping pass towards
/// the interpolated result at a rate determined by <see cref="PositionMaxInterpolationTime"/>.<br />
/// This is frame rate independent for all <see cref="InterpolationTypes"/>, but the same value will not

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2

This guarantee is not true for LegacyLerp: UpdateInterpolation continues to route that mode to the three-argument legacy overload, whose final smoothing factor remains deltaTime / MaximumInterpolationTime. Repeated application of that factor produces different convergence at different frame rates, whereas only the newer Lerp and SmoothDampening path uses the new retention formula. The same inaccurate sentence is repeated for rotation and scale. Limit the claim to the two updated modes (or make the legacy implementation time-independent if that compatibility change is intended), so users do not select LegacyLerp expecting frame-rate-invariant smoothing.

🤖 Helpful? 👍/👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant