graphics
[Cinemachine] Programmatically Adjust Orbital Follow Position Damping
Solution
Unity 2022.3.x - Unity 6.3.x
Published Thu, Mar 26
Developers often encounter issues when attempting to modify camera smoothing at runtime in the updated Cinemachine 3.x API. The specific hierarchy of TrackerSettings within the CinemachineOrbitalFollow component is not immediately intuitive, leading to errors when trying to access PositionDamping directly.
Quick-Fix
To update tracking behavior, developers must access the TrackerSettings property on the CinemachineOrbitalFollow component and assign a new Vector3 to its PositionDamping field.
using UnityEngine;
using Unity.Cinemachine;
public class CameraDampingController : MonoBehaviour
{
[SerializeField] private CinemachineOrbitalFollow orbitalFollow;
private void Update()
{
// Toggle snappy tracking when space is held
if (Input.GetKeyDown(KeyCode.Space))
{
// Remove damping for immediate response
orbitalFollow.TrackerSettings.PositionDamping = Vector3.zero;
}
else if (Input.GetKeyUp(KeyCode.Space))
{
// Restore default smoothing values
orbitalFollow.TrackerSettings.PositionDamping = new Vector3(1f, 1f, 1f);
}
}
}
Related Posts Haven't quite found a solution to your problem? We think these posts might help you.
[Cinemachine] Eliminate Choppy Camera Motion[Cinemachine] Snap <code>CinemachineOrbitalFollow</code> Instantly During Teleportation[2D Sprites] Master Dynamic Visual Depth Control
Content inspired by a Unity discussion post.