Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

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:
    17
    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:
    1,740
    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
     
    BrandStone likes this.
  3. BrandStone

    BrandStone

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