How do you use Cinemachine Camera instead of Main Camera?

I created a Cinemachine Virtual Camera and when I disable Main Camera, I get this No Cameras Rendering.

I tried adding Cinemachine Brain to it with no luck.

The CinemachineVirtualCamera does not replace the main camera. It works alongside it and effectively controls it when the main camera has a CinemachineBrain component. So, you should keep the main camera and add a CinemachineBrain to it. Then, create a CinemachineVirtualCamera as a separate GameObject, not a parent or child of the main camera. Do not put a brain on the virtual camera.

All of this will get done automatically for you if you create the virtual camera from the Cinerachine menu:

I did have it set up like that. But, I could only see through the Main Camera. I set up the virtual camera to act like a first person camera, but all I see is what my Main Camera sees. The virtual camera does absolutely nothing.

The virtual camera needs to be on a layer included in the main camera’s culling mask, otherwise it will be ignored.

Culling Mask on Main Camera is “Everything”. Layer on Virtual Camera is “Default”.

I’m using RobotKyle asset. I believe it was made by Unity. My goal is to have a first person and third person camera to switch between. I was going to create two cameras and adjust the settings, which is probably the easiest way (since I already know how to do that). Then, I came across a tutorial showing Cinemachine and it “looked” easier since all the necessary scripts were already done for you. But, something isn’t working right with it. Maybe I missed something.

When you have the virtual camera and the main camera has a CMBrain component, as I described above, then the main camera should immediately position itself where the virtual camera is. When you move the vcam, the main camera will also move. You are always looking through the main camera, but it’s controlled by the vcam

Try it in an empty scene.

If you’re not getting that behaviour, then your setup is not what I imagine it to be. Can you show some inspectors and the scene hierarchy?

Main Camera:

9447185--1325744--upload_2023-11-2_16-58-34.png

First Person Camera (V Cam):
9447185--1325747--upload_2023-11-2_16-59-26.png

Hierarchy:
9447185--1325750--upload_2023-11-2_17-0-1.png

Robot Kyle:
9447185--1325753--upload_2023-11-2_17-0-29.png

Any other inspectors you would like to see? Please let me know. Thanks.

Is it possible that you have another camera component in the scene? If so, you might be seeing through that one instead of the main camera. Remove it.

Did you try an experiment in an empty scene?

Not yet. About to do that.

Ok. I think I have a different issue. The camera I am seeing is the Virtual Camera. I just made a virtual camera adjustment and it changed the view. I think my problem is that my virtual camera isn’t set up properly to get it to look “through the eyes” of the player. It’s a first person camera, so I just have to figure out what settings are messed up.

So, I’ve determined that my mouse controls the camera. The camera isn’t following the player, even though it’s set to follow the player. As you can see in this picture, the camera is looking at Earth, but my player is not.

The easiest way to make a first person camera with CM is to simply make the vcam a child of the player object that the mouse controls. Put it where the eyes would be. Turn off all procedural settings in the vcam (it doesn’t need to do anything): set Aim and Body to “Do Nothing”, remove the LookAt and Follow targets, and remove the Offset extension. This will create a passive vcam that is controlled by its transform.

It should look something like this:

I disabled Cinemachine cameras and adjusted main camera myself. Making Third Person and First Person views that way was super easy. Is there any reason I want to use Cinemachine? What are the benefits of Cinemachine versus built-in cameras?

By the way, I don’t want my mouse to control the camera, so I plan on changing that. I want to use left and right arrows for player rotation and up and down for movement. I plan on the camera being controlled 100% entirely based on the direction the player is facing.

I might include a look function to allow you to look around with the camera, but it’ll be on Mouse click, rather than anytime you move the mouse and when you release the mouse click, it’ll go back to the camera view. I think the best way to handle this is to rotate the player’s head (on mouse click) and if the camera follows the player’s POV, then rotating the head will also rotate the camera to look wherever the player is looking. That’ll be easy. I just need to determine if I want to try it with Cinemachine, or just create two built-in cameras.

Also, I’ve had bad experiences making a camera a child of player. That is the easiest way to handle it. But, if there’s any abnormal rotation or collisions, it messes up the camera.

Having a single Unity camera that is controlled by multiple CM vcams allows you to implement complex camera behaviours by blending between vcams, each implementing a simple behaviour. It lets your cameras become part of the Cinemachine ecosystem, which gives you blending, Timeline integration, and procedural motion (noise, Impulse, other cameras that look at or follow procedurally, group targeting and framing, etc). Just use VirtualCameras instead of Unity Cameras. If you don’t need any of that stuff then by all means use normal Unity cameras.

Instead of making the camera a child you can make it a separate GameObject, and give the vcam the following procedural behaviour:

Follow Target: player’s eyes
Body: Hard Lock To Target
Aim: Same As Follow Target

9447308--1325792--upload_2023-11-2_17-41-52.png

To move the camera, you can have a custom script to manipulate the rotation of the Player Eyes object.

Ok, I’ll play around with these two options. I appreciate it.

Right now the VCam is a child of player and appears to work. I just need to probably freeze player rotation, I think on the x-axis. If the player does any kind of wierd tumbles, the camera would tumble with him.