Camera keeps reverting back to main StateDrivenCamera

Hi, I am trying to setup cinemachine so that:

When I am walking around I use the MAIN CHARACTER CineMachine Free Look Camera as a third person camera. Works fine.

But then when I try to get on a dragon and ride the dragon through the air the camera changes from: CM_ThirdPerson (MAIN CHARACTER camera) to: CM_ThirdPerson_Dragon camera which is another CineMachine FreeLook camera.

Here’s the setup hierarchy:

CM StateDrivenCamera1
CM_ThirdPerson (MAIN CHARACTER FreeLook)
CM vCam1 Crouch

CM_ThirdPerson_Dragon (FreeLook camera with required different settings)

To accomplish this I used the script as supplied here:

As below:

using Cinemachine.Utility;
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Serialization;
public class vCamSwitch : MonoBehaviour
{
    public GameObject vcam;
    void OnTriggerEnter(Collider other)
    {
        switchToThisVcam();
    }
    void OnTriggerExit(Collider other)
    {
        switchVcamOff();
    }
    public void switchToThisVcam()
    {
        vcam.gameObject.SetActive(true);
    }
    public void switchVcamOff()
    {
        vcam.gameObject.SetActive(false);
    }
}

Now this all works except for one issue.

When I trigger the camera change through a trigger collider on the Dragon the camera changes as expected but then keeps reverting to the original camera.

This camera revert issue occurs when I press the right trigger to gain height on the Dragon.

The blend between cameras occurs back to the: CM StateDrivenCamera1 then reverts back to the: CM_ThirdPerson_Dragon camera when I release the controller right trigger.

But I am still flyng the Dragon and still within the collider I created with the trigger camera change script above attached.

Any ideas how to fix this?

Here’s the Brain settings:

I am currently researching this so will add ADDITIONAL NOTES as they become available.
Any help appreciated, thanks.

My guess would be that in fact you are exiting the collider when you gain height on the dragon. Can you add Debug.Log statements to OnTriggerEnter and OnTriggerExit to prove that they are being called only when you think they are?

1 Like

Thanks for the response. I believe I fixed it. The cause (I believe?) was that the dragon had a Head Follow script attached and the camera (when accelerating) zoomed closer into the target (Head) which I believe caused what you suggested.

Thanks anyway.