0
\$\begingroup\$
using System;
using UnityEngine;
using UnityEngine.UI;
using Cinemachine;

public class CameraSwitch : MonoBehaviour
{
    public CinemachineVirtualCamera vcam;
    public CinemachineFreeLook fcam;
    
    private void Update()
    {
        if(Input.GetKeyDown(KeyCode.V))
        {
            fcam.enabled = false;
            vcam.enabled = true;
        }
    }
}

When pressing on the V key it's switching between the cameras. I want that if I will press on the V key again it will switch between the two camera back fcam to be true and vcam to be false and so on each time pressing on the V key to switch between the cameras.

\$\endgroup\$
2
\$\begingroup\$

I'm assuming you tried something simple like this?

private void Update()
{
    if(Input.GetKeyDown(KeyCode.V))
    {
        fcam.enabled = !fcam.enabled;
        vcam.enabled = !vcam.enabled;
    }
}
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.