[Cinemachine] Snap <code>CinemachineOrbitalFollow</code> Instantly During Teleportation
Solution
Unity 2022.3.x - Unity 6.3.x
Published 2 days ago
The CinemachineOrbitalFollow component fails to snap instantly when PositionDamping is active, resulting in a laggy transition during player teleportation. Additionally, the ForceCameraPosition rotation parameter often fails to override the internal orbital axis values.
CinemachineOrbitalFollow maintains internal interpolation buffers to ensure smooth tracking. When PositionDamping is active, the component interprets a sudden change in position as a distance to be smoothed over time, rather than a discrete jump. Even when calling ForceCameraPosition, these damping values remain active, resulting in a visible slide toward the new coordinates.
To achieve an immediate snap:
- Access the
CinemachineOrbitalFollowcomponent on your script. - Store the current PositionDamping values and then set them to
Vector3.zero. - Call the
ForceCameraPositionmethod with the desired world space position. - Restore the original PositionDamping values to resume smooth tracking.
In Unity 6 and Cinemachine 3.x, the preferred method for handling discrete jumps is notifying the camera system that a warp has occurred. This automatically clears all internal velocity and damping buffers for every component attached to the CinemachineCamera.
Additional Tips
- Use the
OnTargetObjectWarpedmethod on theCinemachineCamerato synchronize all components, includingCinemachinePositionComposerorCinemachineOrbitalFollow, with a single call. - If you need to snap the orbital rotation specifically, modify the
HorizontalAxis.ValueandVerticalAxis.Valueproperties directly, asForceCameraPositionprimarily handles the physical placement of the camera transform. - Ensure your script executes the teleport logic before the
LateUpdatephase where Cinemachine typically processes its movement logic. - If the target is a
Rigidbody, ensure the warp happens inFixedUpdateto maintain physics consistency before the camera updates.
TL;DR
To resolve interpolation lag, manually reset PositionDamping or invoke the OnTargetObjectWarped API to synchronize the camera with your script.
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.