Hi @Gregoryl , sorry for the late anwser.
Here are more infos. Basically I have two scripts for the camera behaviour.
On VCAMS, I have this incredible code containing a list of all the cameras I want to blend back and forth to. I manually set them in the editor. The idea here is to call them by index whenether I need to activate and deactivate them (on trigger zones etc).
using UnityEngine;
using System.Collections.Generic;
using Cinemachine;
public class ActivateCam : MonoBehaviour
{
public CinemachineVirtualCamera[] levelCameras;
}
On the trigger zone, the second script does a very basic activation/deactivation toggle.
using UnityEngine;
using Cinemachine;
public class SwitchCamOnTrigger : MonoBehaviour
{
// Enter the target index of the camera
public int index;
public GameObject VCAMS;
public CinemachineFreeLook mainCamera;
private CinemachineVirtualCamera switchedCam;
// Player
public Collider player;
public Collider triggerCollider;
private void Awake()
{
triggerCollider = GetComponent<Collider>();
switchedCam = VCAMS.GetComponent<ActivateCam>().levelCameras[index];
// switchedCam deactivated by default
switchedCam.gameObject.SetActive(false);
}
// On TriggerEnter
// Activate switchedCam
// Deactivate the mainCamera
private void OnTriggerEnter(Collider other)
{
if (other == player)
{
switchedCam.gameObject.SetActive(true);
mainCamera.gameObject.SetActive(false);
}
}
// For safety
// On TriggerStay
// Keep switchedCam activated
private void OnTriggerStay(Collider other)
{
if (other == player)
{
switchedCam.gameObject.SetActive(true);
}
}
// On TriggerExit
// Deactivate switchedCam
// Activate the mainCamera
private void OnTriggerExit(Collider other)
{
if (other == player)
{
switchedCam.gameObject.SetActive(false);
mainCamera.gameObject.SetActive(true);
}
}
}
I was wondering if the issue is not coming from the inputs of the Freelook camera. Here is the code (the hack) on the mainCamera’s inputs because I’m using the new Input system : Cinemachine FreeLook camera and New Input System?
Thanks for your help and stay safe.