Problem with VirtualCameraGameObject

Hi again, In my game i am needing a reference to my freelook camera to set the tracking and look at functions in C#. the problem is though that when i try to use

c_VirtualCam = camTransform.GetComponent<CinemachineBrain>().ActiveVirtualCamera.VirtualCameraGameObject.GetComponent<CinemachineCamera>();

I get an error saying that “ICinemachineCamera’ does not contain a definition for 'VirtualCameraGameObject” and I don’t know what to do. is there someone who can help?

Try this instead:

var vcam = camTransform.GetComponent<CinemachineBrain>().ActiveVirtualCamera as CinemachineCamera;
if (vcam != null)
{
    // bla bla bla
}
2 Likes

Thanks that works!

1 Like