Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Resources discussing the use of Cinemachine with XR/Virtual Reality

Discussion in 'Cinemachine' started by alexchesser, Jan 27, 2020.

  1. alexchesser

    alexchesser

    Joined:
    Sep 15, 2017
    Posts:
    147
    Hi Folks,

    Not really sure if this is better posted here or within the XR discussion forum. Rolling the dice.

    I've been thinking a bit about how to combine the magic of Cinemachine with a VR game. A few things I'd like to be able to do is move through a few different perspectives: world overview, third person follow, first person.

    Cinemachine brings so much to the table that if I were a non-VR game I would just set a few VCAMS at various points in the scene and adjust the cam-weight at runtime. The complication arises because of how integral that rig setup happens to be with respect to VR.

    Typically in VR you'd see the "center eye anchor" as the main camera, but the left hand and right hand anchors are positioned relative to the C.E.A ... and then the "tracking space" is your safe play zone.

    I think that essentially the entire OVRCameraRig would have to move from one VCAM to another ... but then how would you handle smooth blending between them?

    upload_2020-1-27_15-27-29.png

    I've actually got a million questions about leveraging cinemachine in VR - but - before I run through a couple of weekends doing prototyping and research (for example: do I make my VCAMs children of the CEA? Does that cause motion sickness?) Does head tracking break when you use a VCAM followcam? Maybe if I followcam while leaving LOOK CAM set to null? what if I want *some* player guidance with a set look cam, but I still want them to be able to move their head (effectively making the world at the center-eye update while the player retains full head movement within that guided movement)?

    I'd like to know if there are any resources out there from people who have thought about and solved these problems before? Is there anyone on the internet who's got some insight into the scope of the problem here?

    Is there any thought leadership out there on this topic?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    4,623
    This topic has come up before, and the consensus seems to be something along these lines:
    1. VR rig needs direct control of the camera, so you can't let CM directly control the camera or they will fight.
    2. You can set up CM to control the location of parent of the VR rig, allowing VR to position the camera in relation to that. Do it like this:
      1. Remove the CM Brain component from the Camera, if one is there
      2. Manually add a CM Brain to the parent of the VR rig. Then, any vcams in your scene will drive the transform of that parent object instead of the camera. Blends etc will all function normally, but CM will not be able to control the camera lens (which for VR is the right thing)
    3. Be very cautious with vcam movement, or you may expose your victim to motion sickness
     
    Last edited: Jun 3, 2020
    Kjelle69 and alexchesser like this.
  3. alexchesser

    alexchesser

    Joined:
    Sep 15, 2017
    Posts:
    147
    Fantastic answer Gregoryl! Thanks so much :) I'm laughing a little. I did manage to find your other thread on this topic from a few years ago (https://forum.unity.com/threads/vr-follow-player-car.500018/). I'll be sure to turn up the damping on all axes
     
    Gregoryl likes this.
  4. alexchesser

    alexchesser

    Joined:
    Sep 15, 2017
    Posts:
    147
    Hey @Gregoryl I'm trying the follow-cam configuration now and I've got a few questions. I think it's a strong first showing for what I'm *hoping* to get to - but I think there are some configuration things I'm missing. And maybe some odd behaviors from my non-standard config.

    The first thing I've noticed is that the guide rails don't seem to be showing up anymore when working in editor. I think if they were still around I'd have an easier time getting the actual follow behavior I'm looking for.

    When I get ingame on a VR headset
    Here's a quick video of the actual activity - recorded from an Oculus Quest headset


    I'm seeing that I'm not actually staying on one side of the character. I think Ideally I'd like to design for a seated experience where you, stay on the SOUTH side of the character. Notice how at the end of the video I actually have to turn my head 180 degrees to look at the character? And how it's possible to run out-of-frame? Are there settings that will let me always stay "below" the character?

    this is my current VCAM configuration and hierarchy.

    upload_2020-2-9_14-6-28.png
     
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    4,623
    It's the binding mode. Binding mode controls how the follow offset is interpreted, and SimpleFollow interprets it in Camera-space. Set it to World Space, and then set the offset to be south of the player.
     
    alexchesser likes this.
  6. HAIRGROW

    HAIRGROW

    Joined:
    May 17, 2013
    Posts:
    8
    So I'm starting to fiddle with Cinemachine and VR as well, but my approach/question is different. I'd like to use Cinemachine as a spectator camera and be able to create a sequence of camera shots between the VR camera and other "cameras" around the player as the move about the world. At first glance it seems this is impossible because Cinemachine wants to take over the Main Camera. I tried adding a Brain to a second camera and then adding a Virtual Camera, but it took over the VR camera. Is it possible to use Cinemachine on another camera that's not tagged as the Main Camera?
     
  7. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    4,623
    Yes. Attach a CinemachineBrain to the camera you want, and make sure to remove any CinemachineBrain from the VR camera. Cinemachine will drive the transform of any object that has a CinemachineBrain attached to it (it doesn't even need to be a camera at all).
     
  8. HAIRGROW

    HAIRGROW

    Joined:
    May 17, 2013
    Posts:
    8
    Aww, sweet it worked! Thank you for such a quick response. I didn't realize a brain had been added to the VR camera. Once I removed it, and then created a Spectator Camera, added the Brain to it, and then created a dolly camera with track, it worked. I've wanted to use Timeline and Cinemachine for quite awhile. As a solo dev I finally reached a point where I want to demonstrate my Locomotion mechanic, Ninja Run, but its hard to describe with just the VR camera. The player has a fully rigged body, with Index Controller finger tracking, so Cinemachine should be a perfect fit for VR cinematic.

    Do you have any tips that could help with switching between the Vcams and the Player camera. I know I need to do a little more research, but I'd like to setup my shots around the virtual world, and then use colliders to trigger camera transitions / cuts.
     
  9. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    4,623
    One way to do it would be to attach a passive CinemcahineVirtualCamera behaviour (passive = DoNothing in Aim and Body) to the VR camera, and set its lens settings to mimic the VR camera's. That will give you a vcam that exactly shadows the VR camera (because its transform is the same as the VR camera). Then when you want to blend to some other vcam, start by activating the shadow vcam along with the CM camera (with the Brain) at the same time as you deactivate the VR Camera behaviour. That makes the CM camera take on the same position and lens as the VR camera, as well as take over the screen. After that you can blend nicely to any other vcam. Reverse the procedure to blend back.

    Does that make sense?
     
    Kjelle69 likes this.
  10. HAIRGROW

    HAIRGROW

    Joined:
    May 17, 2013
    Posts:
    8
    Hey there Gregory. My apologies but I am just seeing your response. It does indeed make sense. I will be looking to implement this is the next few days. I've been focusing on other areas of the project that will lead up to making full use of Cinemachine.
     
unityunity