[Input System] Solve Physics Stuttering and Input Response Lag
Solution
Unity 2021.x - Unity 6.3.x
Published 24 days ago
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.
To resolve physical movement inconsistencies, decouple input logic from physics logic using a buffered approach.
-
Capture the input values within your script using the
Updatemethod or Input System event callbacks. -
Store these values in a member variable to act as a buffer.
-
Apply the movement logic to the Rigidbody inside the
FixedUpdatemethod usingAddForceorMovePosition. -
Ensure the Rigidbody component’s
Interpolatesetting is set toInterpolate. This allows Unity to calculate the visual transform between the last two physics steps, removing the appearance of jitter on high-refresh-rate monitors. -
If the lag persists, adjust the
Fixed Timestepin Project Settings to align more closely with your target frame rate, though 0.02 (50Hz) is standard.
Additional Tips:
- Use
InputManager.fixedEventsin theInputSystemsettings if you require input to be strictly aligned with the physics loop. - Avoid using
Time.deltaTimeinsideFixedUpdate; useTime.fixedDeltaTimeor rely on the engine’s internal physics scaling. - Check for
Physics.Processingspikes 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.