Cinemachine camera which only moves when target goes into soft bounds

Hi, I’d like to have a virtual camera which only follows the target whenever the target reaches the softzone. Within the deadzone the target can move however it wants without the camera transform changing.

It’s a 3d setup (my plane is in the xz space).

I’d tried setting this up with a framing transposer, but that changes Y coordinate to maintain the distance to the target and the z depth delta also moves the coordinates within the dead zone.

I’ve been looking into creating a custom extension for this, but I was wondering if there is an easier way to achieve this kind of behaviour?

There is nothing out of the box to make that work perfectly, but you can come pretty close using a vcam with FramingTransposer in the Body, and DoNothing in the Aim. You need to set the FramingTransposer’s Dead Zone Depth to an appropriate size.

You have to play around with the settings, depending on the desired camera-target relationship. Don’t expect perfection (due in part to perspective), but you can get it to be pretty nice.

I set it up with my vcam looking down at the target from a 20 degree angle, and these settings in the Framing Transposer:

You need to add a custom extension to lock the Y position. Here is what I used:

using UnityEngine;
using Cinemachine;

/// <summary>
/// An add-on module for Cinemachine Virtual Camera that locks the camera's Y co-ordinate
/// </summary>
[SaveDuringPlay] [AddComponentMenu("")] // Hide in menu
public class LockCameraY : CinemachineExtension
{
    [Tooltip("Lock the camera's Y position to this value")]
    public float m_YPosition = 10;

    protected override void PostPipelineStageCallback(
        CinemachineVirtualCameraBase vcam,
        CinemachineCore.Stage stage, ref CameraState state, float deltaTime)
    {
        if (stage == CinemachineCore.Stage.Finalize)
        {
            var pos = state.RawPosition;
            pos.y = m_YPosition;
            state.RawPosition = pos;
        }
    }
}

Thank you for the feedback!