Search Unity

Sync Free Look Camera with Virtual Camera before transition

Discussion in 'Cinemachine' started by BrandStone, Sep 5, 2018.

  1. BrandStone

    BrandStone

    Joined:
    Jul 21, 2014
    Posts:
    79
    I have two cameras set up in my project. One is a Free look camera for over the shoulder and the other one is a target camera set to follow the player and look at one enemy.

    When I switch to target camera all is well: the virtual camera does the tracking, the fight goes on. But when I transition from the virtual camera back to the free look camera, the perspective will switch back to where the free look camera was before. But what I would like to achieve is to not see any transition between them.

    In the code I have a method that switches between free look and virtual camera.

    Code (CSharp):
    1. void ToggleTargetCamera ()
    2. {
    3.     this.hasTargetLock = !this.hasTargetLock;
    4.  
    5.     if (this.hasTargetLock)
    6.     {
    7.         orbitCamera.Priority = 10;
    8.         targetCamera.Priority = 20;
    9.     }
    10.     else
    11.     {
    12.         // Sync cameras here
    13.         MakeOrbitCameraParamsAsTargetCamera();
    14.  
    15.         orbitCamera.Priority = 20;
    16.         targetCamera.Priority = 10;
    17.     }
    18. }
    How could I achieve this?
    Thanks
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    I'm assuming that "where the free look was before" refers to its position on the orbit? You want the axis value to be such that the camera moves as little as possible in the blend?

    You'll need to do 2 things to make this happen:
    1. Upgrade CM to 2.2.8 (not released yet, but available in preview on the staging repository)
    2. Check the "Inherit Position" checkbox on both vcams
    upload_2018-9-5_12-23-51.png

    See this thread: https://forum.unity.com/threads/que...to-world-space-free-look.548332/#post-3622498
     
    ManishOtaval and BrandStone like this.
  3. BrandStone

    BrandStone

    Joined:
    Jul 21, 2014
    Posts:
    79
    Oh yes, that's exactly what I need. Thanks, I'll check out 2.2.8. :)