I have seen some tutorials, but they all use old cinemachine 2 which is currently not supported.
I tried doing similar thing and have this:
int Zvalue = THE_SHOOTER.zoom(true);
if (Zvalue == 0)
{
for (int i = 0; i < THE_SHOOTER.ZoomIn.cameras.Count; i++)
{
CinemachineCamera VirtCam = THE_SHOOTER.ZoomIn.cameras[i].GetComponent<CinemachineCamera>();
VirtCam.Priority = 0;
}
//mainCam.SetActive(true);
}
else
{
//mainCam.SetActive(false);
for (int i = 0; i < THE_SHOOTER.ZoomIn.cameras.Count; i++)
{
CinemachineCamera VirtCam = THE_SHOOTER.ZoomIn.cameras[i].GetComponent<CinemachineCamera>();
VirtCam.Priority = 0;
}
CinemachineCamera VirtCamSelected = THE_SHOOTER.ZoomIn.cameras[Zvalue - 1].GetComponent<CinemachineCamera>();
VirtCamSelected.Priority = 2;
}
I have main camera with cinemachine camera with priority 1 and second camera with cinemachine camera with priority 0 that changes to 2 with code, but swith to second camera doesnt happen.
I also have cinemachine brain in scene.
I can confirm that priority actually changes to required values.
Switching cameras is still priority based.
Try the following:
- enter playmode
- select a Cinemachine object that isn’t currently the “live” camera
- edit the priority field and change it to be the highest priority (eg 100)
You should then see the camera switch (blends over 2 seconds by default).
If the camera doesn’t switch, check the active camera’s priority to ensure it isn’t perhaps 1000. Select the CinemachineBrain (on the Camera) to see what the active camera is, and if you click it you can jump right to it.
Seeing that you probably have many virtual cameras you may simply have a duplicate somewhere which activates but since it has the same properties of the previous live camera you may not see any visual changes.
Here’s a cleaned up version of that code:
int zValue = THE_SHOOTER.zoom(true);
var camList = THE_SHOOTER.ZoomIn.cameras; // Extracting the list once
// 1. Reset all priorities to 0
foreach (var camObj in camList)
{
if (camObj.TryGetComponent(out CinemachineCamera virtCam))
virtCam.Priority = 0;
}
// 2. Set active camera if zValue is valid
if (zValue > 0 && zValue <= camList.Count)
{
if (camList[zValue - 1].TryGetComponent(out CinemachineCamera selectedCam))
selectedCam.Priority = 2;
}
I only have 2 cameras currently with intention to add more later.
Changing priorities doesnt do anything at all. If code is correct then maybe my setup is incorrect?
And cinemachine brain shows correct camera that is supposed to be active, but nothing happens.
This is main camera.
That doesn’t look to be a correct set up. I would familiarise yourself with the basics of Cinemachine: Cinemachine essential elements | Cinemachine | 3.1.6
When using it, you only need the one camera with a CinemachineBrain component also attached to it.
Then you put CinemachineCamera components on different game objects. These are your ‘virtual cameras’. Then there is various ways to swap between these virtual camera, the easiest being to simply disable/enable the component.

Are you sure about camera with a CinemachineBrainalso attached to it?
This setup kinda works, but first camera loses it’s position so doesnt really work
That error is probably because you still have the CinemachineCamera component on the same game object. Remove it and put it on a separate game object.
It doesn’t seem like you have read the documentation:
Please read the documentation first before continuing to ask questions.