UnityRef is currently in early development. Some features may be incomplete and/or not functioning.

UNITYREF

Your Pit Stop For Solving ANYTHING in Unity

physics

[Input System] Solve Physics Stuttering and Input Response Lag

Solution

physicsinput systemrigidbodyoptimizationperformance

Unity 2021.x - Unity 6.3.x

Published 24 days ago

Issue

 Visible stuttering and inconsistent input lag occur when moving a Rigidbody using the new Input System. This happens because the input polling frequency often desyncs from the FixedUpdate interval, causing forces to be applied irregularly or input values to be missed entirely during physics steps.

Explanation

To resolve physical movement inconsistencies, decouple input logic from physics logic using a buffered approach.

  1. Capture the input values within your script using the Update method or Input System event callbacks.

  2. Store these values in a member variable to act as a buffer.

  3. Apply the movement logic to the Rigidbody inside the FixedUpdate method using AddForce or MovePosition.

  4. Ensure the Rigidbody component’s Interpolate setting is set to Interpolate. This allows Unity to calculate the visual transform between the last two physics steps, removing the appearance of jitter on high-refresh-rate monitors.

  5. If the lag persists, adjust the Fixed Timestep in Project Settings to align more closely with your target frame rate, though 0.02 (50Hz) is standard.

Additional Tips:

  • Use InputManager.fixedEvents in the InputSystem settings if you require input to be strictly aligned with the physics loop.
  • Avoid using Time.deltaTime inside FixedUpdate; use Time.fixedDeltaTime or rely on the engine’s internal physics scaling.
  • Check for Physics.Processing spikes in the Profiler to ensure complex colliders aren’t the root cause of the frame drops.

TL;DR

Synchronize input collection in Update with force application in FixedUpdate and enable Rigidbody interpolation to bridge the gap between physics frames and rendered frames.


Related Posts Haven't quite found a solution to your problem? We think these posts might help you.

Content inspired by a Unity discussion post.