[Cinemachine] Eliminate Choppy Camera Motion
Solution
Unity 2022.3.x - Unity 6.3.x
Published Tue, Mar 17
When an object being followed by a Cinemachine camera approaches the camera's view borders, the camera movement may exhibit a jagged or jerky motion. This issue is particularly noticeable with orbital follow position damping and leads to an undesirable visual stuttering during tracking.
Erratic camera movement often arises from the continuous application of position damping, even for minute target movements, without a defined dead zone. This constant micro-adjustment can result in a perceptible jerky visual effect when the target is near the edges of the camera’s active tracking area.
The resolution involves modifying your script logic to incorporate a clamping mechanism for positional deltas. This modification introduces a dead zone by ensuring that minor target movements do not trigger immediate camera adjustments. The objective is to stabilize the camera behavior when the target remains within a small, permissible range.
- Locate the positional tracking update loop in your script.
- Calculate the
dampingSpacebased on the camera’sRawOrientationorLookRotation. - Identify the
localDeltaby transforming the target’s position delta into the damping space. - Apply a
ClampMagnitudefunction to thelocalDeltabased on the effective damping settings. - Implement a conditional check against
UnityVectorExtensions.Epsilonto determine if the delta is significant enough to move the camera.
Additional Tips
- Match your camera’s update method with the target’s movement cycle (e.g.,
FixedUpdatefor physics-based targets). - Use the
CinemachineCamerainspector to verify if the ‘Soft Zone’ is too large, which can exacerbate tracking jitter. - Ensure the damping values are not set to extremely high levels, as this forces the camera to lag significantly behind targets.
TL;DR
Jagged camera movement can be resolved by implementing a dead zone within the Cinemachine camera's tracking logic to prevent micro-adjustments from triggering damping.
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.