Cinemachine GenerateCameraActivationEvent doesnt change camera

i have the following code:

    public CinemachineVirtualCameraBase FreeFormCamera;
    public CinemachineVirtualCameraBase TargetingCamera;
    public CinemachineVirtualCameraBase AimCamera;

    public MotionController PlayerMotionController;
    public Combatant PlayerCombatant;

    public CinemachineBrain Brain;

    public CinemachineVirtualCameraBase ActiveCamera;


    private void Start()
    {
        ActiveCamera = FreeFormCamera;
        ActiveCamera.Priority = 1;
        TargetingCamera.Priority = 0;
        AimCamera.Priority = 0;
        CinemachineCore.Instance.GenerateCameraActivationEvent(ActiveCamera, null);
    }


    private void Update()
    {
        if (PlayerCombatant.IsTargetLocked)
        {
            ChangeCamera(TargetingCamera);
        }
        else
        {
            ChangeCamera(FreeFormCamera);
        }
    }


    private void ChangeCamera(CinemachineVirtualCameraBase camera)
    {
        if (ActiveCamera != camera)
        {
            CinemachineCore.Instance.GenerateCameraActivationEvent(camera, ActiveCamera);
            ActiveCamera = camera;
        }
    }
}

When i run the GenerateCameraActivationEvent nothing happens and the camera doesn’t change.

Can anyone see what I’ve done wrong?

That’s not how you activate virtual cameras. The event is generated by a vcam becoming activated, not the other way around.

Activate a virtual camera by raising its priority or by activating its game object.

Thank you for your quick response. How does this work with the blends i have?

When a new vcam is activated (or prioritized), the CM Brain will blend from the outgoing vcam according to the default blend defined within the brain, or the custom blend settings, if one applies to the transition.

6342651--704688--upload_2020-9-23_19-50-18.png

1 Like

This worked thank you a lot!