Search Unity

Cinemachine back to main camera help!

Discussion in 'Cinemachine' started by fiendishdraws, Nov 29, 2018.

  1. fiendishdraws

    fiendishdraws

    Joined:
    Oct 1, 2017
    Posts:
    6
    Hi! Sorry to bother you all but I have a question concerning cinemachine and timeline. I have a main camera, the camera within my FirstPersonCharacter but wanted to create a simple cutscene with cinemachine. I made a timeline and then added a cinemachine brain to different camera objects within the same scene. Each Camera object have a virtual camera in place. I added all the brains to the timeline. Is it possible for cinemachine to end there and return to my main camera viewport? It seems no matter what I do, it simply stays in the perspective of one virtual camera.

    Sincerely,

    Ed
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    You've not set this up quite correctly.

    You should have a single Unity Camera, with a single Brain on it.

    Then, you create multiple VirtualCamera objects. Say you have one for the main gameplay, and a number of others referenced from the timeline. The CM timeline tracks are all bound to the single Brain, with individual clips on the tracks bound to the vcams.

    Now, when you run the timeline, the vcams referenced from it will drive the main camera. When the timeline stops, control will be returned to the gameplay vcam.

    So remember the paradigm: one Camera, one Brain, many vcams.
     
  3. fiendishdraws

    fiendishdraws

    Joined:
    Oct 1, 2017
    Posts:
    6
    Ok thanks but my main camera doesn't use a virtual camera. Is it possible to simply return back to my FPS controller's camera? Or do I have to attach a virtual camera to my FPS controller. I have effects on my camera on it already so it would be a hassle.
     
    Last edited: Nov 29, 2018
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    What you can do in this case is to replace the FPS controller's Camera component with a CinemachineVirtualCamera component with a higher-than-default priority. That will become the main gameplay camera.

    So in summary:
    1. Have a top-level gameobject with Camera and CinemachineBrain. This is your scene's one and only camera.
    2. Replace the Camera component in the FPS controller with a CinemachineVirtualCamera component. Put "Do Nothing" in both Aim and Body. This turns off the procedural features and allows your vcam to be 100% driven by its trransform, which is controlled by your FPS script. Make this the default vcam by giving it higher priority. Now you have the equivalent of your original FPS system, but with the possibility to blend this camera with other vcams, add noise, impulse, etc.
    3. Create timelines with other vcams to use in cutscene. For performance, you can disable those other vcam gameObjects, they will be force-enabled when invoked from the timeline.
     
    Nubaa likes this.
  5. fiendishdraws

    fiendishdraws

    Joined:
    Oct 1, 2017
    Posts:
    6
    Thanks so much! It works but unfortunately the AQUAS and Enviro camera script don't.
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    I'm not familiar with those scripts. If they are depending on a Camera component, you might try either or both of:
    • hacking them to use a vcam component instead
    • just disable the Camera component instead of deleting it
     
  7. fiendishdraws

    fiendishdraws

    Joined:
    Oct 1, 2017
    Posts:
    6
    I can fix it apparently by putting them on the main camera. However, I have kept camera disabled in my FPS controller but it seems when I delete it, it breaks everything and the timeline no longer follows my other vcams and then the FPS vcam. It's strange. Also, when I keep the camera disabled on my FPS controller with the vcam, I cant look up or down.
     
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    I can't really tell you what's wrong without seeing the project.

    Another possible approach for you is to keep 2 cameras: one with the FPS and another one, with the brain, for cutscenes only. When the timeline begins, disable the FPS camera and enable the CM camera. When the timeline ends, do the opposite. You won't get blending between them, but maybe that's ok for you.
     
  9. fiendishdraws

    fiendishdraws

    Joined:
    Oct 1, 2017
    Posts:
    6
    Tried, still can't look up or down. It's weird.
     
  10. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    I've seen the up and down thing before - some thread on this forum, in the last month or so, just can't find it. It's the way the controller is built. There is an easy fix, I just don't remember what offhand. Try putting the controller back to what it was before these experiments.
     
  11. HernandoNJ

    HernandoNJ

    Joined:
    May 13, 2018
    Posts:
    75
  12. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    The solution in your blog can work, but there is a much easier and more powerful way.

    Have a standalone Camera GameObject, with a Cinemachine Brain. This camera will always take instructions from the current active virtual camera.

    For your in-game camera, replace the Camera component with a CinemachineVirtualCamera, with Do Nothing in Aim and Body. This is a passive vcam, and is 100% controllable from your camera controller script, just like a normal camera. When no Timeline vcam is active, then this vcam (and hence your camera controller script) will by default control the main camera.

    When a CM Timeline track is active, it will override the default vcam and take control. When the timeline stops, control will automatically be returned to your main camera. You can make these transitions cuts or blends, as you wish.
     
    HernandoNJ likes this.
  13. HernandoNJ

    HernandoNJ

    Joined:
    May 13, 2018
    Posts:
    75
    I made it as described above. *** It works AWESOME! ***
    After fixing some configurations, it worked as required.
    Later I'll update the blog and this post with the process using the info you provided.
    Thank you very much @Gregoryl !

    Blog updated here

    CM Brain and InGameCam
    upload_2021-8-9_17-27-56.png

    Configuring InGameCam options as Main camera
    upload_2021-8-9_17-28-34.png


    Re-assign CM Brain in Timeline
    upload_2021-8-9_17-28-51.png

     
    Last edited: Aug 9, 2021
    Gregoryl likes this.