Cinemachine and VR switch view on button press

Hi,

I’m trying to make a 3rd person view for VR with the option to switch to first person mode

I’ve looked around and Cinemachine seems capable of doing it but I can’t seem to figure out how to actually make the switch, i followed this ( Resources discussing the use of Cinemachine with XR/Virtual Reality ) but it doesn’t match my use case properly

What I’ve done:

  • Created a Seperate Vcam “3rdPCam” and postioned it in the sky
  • Created a seperate game object “CineBrain” and added the cinemachine brain
  • added my VR player rig as a child to “Cinebrain”
  • “3rdPCam” Follow & Set options have been set to the game object, body binding mode has been set to ‘World Space’

How do I change my normal VR view to the “3rdPCam” and back?

Anyone know how to do it, or how to blend between Virtual Cam and VR cam?

What happens if you disable 3rdPCam vcam?

Nothing - Game still starts in VR View

I’ve also changed my hierarchy as putting my Vr rig under ‘Cinebrain’ was causing it to rapidly spin on all axes whenever i pressed Play

New Hierarchy:

  • Created a seperate game object “CineBrain” and added the cinemachine brain
  • XRRig - VRCamera has a cinemachineVirtualCamera with ‘Do nothing’ in Aim and Body
  • Created a Camera Object “3rdP” and attached a cinemachineVirtualCamera

“CineBrain” can see both virtual cameras, changing the priorty in Play mode will show the camera icon moving between each other but will not change my VR view to the “3rdP” camera

Here is one way I can think of for doing what you want. You’ll need 2 Unity Cameras: one for Cinemachine and one for VR:

  • Standard Unity Camera with a Cinemachine Brain
  • Standard VR rig, with a Camera component inside.

Next, make a CM FreeLook camera (or any other kind of CM vcam). It will work normally with the CM Brain while (1) is active and (2) is deactivated.

To switch to VR, activate (2) and deactivate (1). That will make a cut. To make a blend, do this:

Have another vcam with HardLockToTarget in Body, and SameAsFollowTarget in aim. Use the VR Camera as the follow target. It is a proxy for the VR rig. Blend to it, then swap in the rig by enabling (2) and disabling (1). Do the reverse to blend back.

Does that make sense?

Progress!

I’ve added all the extra cams, bringing my total amount of cameras to 4 within this scene.

Manually changing the priority via the slider on the proxy VR cam results in the Play mode blending from VR view to the 3rd person view :slight_smile:

I don’t understand the activate and deactivate part, as the view will change by manually adjusting the priority on a vcam?

Am i right, assuming that the Standard unity camera I added doesn’t actually need to point at anything to work, so its just a placeholder for CinemachineBrain to control the other vcams?

It’s the other way around: the standard camera with the CM brain is controlled by the vcams. So yes, it doesn’t need to be pointing at anything.

I can’t test it myself because I don’t have a VR rig here at home, so maybe you can tell me. Does it work if you just permanently disable the VR rig’s Camera component, and allow the CM camera to to the job? Then you don’t need to enable/disable anything when you switch modes.

Understood, thanks!

Right now the blending/switch between different modes can be done without anything being disabled - its why i was confused by that statement.

Test
Disable VR rig’s camera component and see if you can switch modes

Result
Disabling VR rig’s camera component results in no change, I am still able to switch modes by manualy adjusting the priority

Here is my Hierarchy ‘UH.png’

‘Player Latest’ is the default ‘Player’ rig that comes with SteamVR, only different is a rig drawer script to make the gizmos a bit bigger

7137284--853433--UH.PNG

So the “dummy camera” isn’t a dummy camera with this setup. It’s the real camera, which in VR mode is matching the disabled VR Camera’s position. You should keep the VR camera disabled, otherwise it’s just spinning cycles for nothing.

Ok will do thanks, but what do you mean by spinning cycles?
The camera doesnt spin around since i changed the hierarchy

I mean wasting CPU cycles. I’m guessing that English is not your first language. It’s hard to tell with a name like BWpAPbkV :wink:

hahaha, i’m just new to unity terminology, so i wasn’t sure what it was referencing.

Thank for the help again!

1 Like