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

UNITYREF

Your Pit Stop For Solving ANYTHING in Unity

graphics

[Cinemachine] Eliminate Choppy Camera Motion

Solution

cinemachine

Unity 2022.3.x - Unity 6.3.x

Published Tue, Mar 17

Issue

 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.

Explanation

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.

  1. Locate the positional tracking update loop in your script.
  2. Calculate the dampingSpace based on the camera’s RawOrientation or LookRotation.
  3. Identify the localDelta by transforming the target’s position delta into the damping space.
  4. Apply a ClampMagnitude function to the localDelta based on the effective damping settings.
  5. Implement a conditional check against UnityVectorExtensions.Epsilon to 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., FixedUpdate for physics-based targets).
  • Use the CinemachineCamera inspector 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.