Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Cinemachine Lock On Camera reset Position

Discussion in 'Cinemachine' started by RonaldoJonson, Aug 22, 2019.

  1. RonaldoJonson

    RonaldoJonson

    Joined:
    Dec 17, 2018
    Posts:
    3
    I have a simple MixingCamera with two child cinemachine cameras (Freelook, and normal virtual camera), I use the second one as a lockon camera and the result is great, But when I change from the lockOn camera back to my freelook camera, I want the freelook camera to start at the same position as the lockOn camera was.

    - I use the Mixing camera Weight 0 and 1 to control which camera is being shown
    - I've tried setting the transform.position, no effect
    - Inherit position, no effect (because the camera never goes (not)live so the transition with inherit position never triggers)


    upload_2019-8-22_18-21-15.png


    upload_2019-8-22_18-21-39.png

    upload_2019-8-22_18-21-54.png
     
  2. piginhat

    piginhat

    Joined:
    Feb 17, 2016
    Posts:
    96
    I don't know if this helps but this is how I reset my cmfreelook camera to a starting point:

    Code (CSharp):
    1.  
    2. public void ConnectCMFreeLook() {
    3.  
    4.         // reset the POV to the default:
    5.         cmFreeLook.PreviousStateIsValid = false;
    6.  
    7.         // reset the x axis
    8.         cmFreeLook.m_XAxis.Value = 0;
    9.        
    10.         // reset the y axis
    11.         cmFreeLook.m_YAxis.Value = 0.5f;
    12.  
    13.         // set look at transform
    14.         cmFreeLook.LookAt = cmFreeLookParameters.lookAtTransform;
    15.  
    16.         // set follow transform
    17.         cmFreeLook.Follow = cmFreeLookParameters.followTransform;
    18.        
    19.         // set height of top rig
    20.         cmFreeLook.m_Orbits[0].m_Height = cmFreeLookParameters.TopRig.x;
    21.  
    22.         // set radius of top rig
    23.         cmFreeLook.m_Orbits[0].m_Radius = cmFreeLookParameters.TopRig.y;
    24.  
    25.         // set height of middle rig
    26.         cmFreeLook.m_Orbits[1].m_Height = cmFreeLookParameters.MiddleRig.x;
    27.  
    28.         // set radius of middle rig
    29.         cmFreeLook.m_Orbits[1].m_Radius = cmFreeLookParameters.MiddleRig.y;
    30.  
    31.         // set height of bottom rig
    32.         cmFreeLook.m_Orbits[2].m_Height = cmFreeLookParameters.BottomRig.x;
    33.  
    34.         // set radius of bottom rig
    35.         cmFreeLook.m_Orbits[2].m_Radius = cmFreeLookParameters.BottomRig.y;
    36.     }
    Obviously cmFreeLook is my cmfreelook camera in the scene and on each of my game objects that have different settings I attach a cmFreeLookParameters class which contains the relevant setting values.

    I have ConnectCMFreeLook attached to the game objects and in play when the change is required I simply call myGameObject.ConnectCMFreeLook();
     
  3. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    It's true that MixingCamera won't call OnTransitionFromCamera when waking up the FreeLook. However, you can call it yourself when you trigger the reactivation of the FreeLook. Make sure that when you call it the FreeLook's weight is 0, otherwise there will be a pop.
     
  4. RonaldoJonson

    RonaldoJonson

    Joined:
    Dec 17, 2018
    Posts:
    3
    S
    Sorry but your way doesn't really work for me because the other camera is not a freelook camera it's a simple virtual camera so it doesn't have the variables you used :(
     
  5. RonaldoJonson

    RonaldoJonson

    Joined:
    Dec 17, 2018
    Posts:
    3
    worked like a charm thx
     
    Gregoryl likes this.
  6. phocus123

    phocus123

    Joined:
    Jul 31, 2015
    Posts:
    7
    Any chance you could expand on what you did to make this work as I am having the same issue. Does the solution have something to do with triggering Inherit Position by calling OnTransitionFromCamera? I have tried doing this in my script before I toggle the weights (just before I set the free looks weight to 1) but didn't seem to have any effect.
     
  7. piginhat

    piginhat

    Joined:
    Feb 17, 2016
    Posts:
    96
    who are you asking to expand?
     
  8. phocus123

    phocus123

    Joined:
    Jul 31, 2015
    Posts:
    7
    Haha I guess RonaldoJonson as he managed to figure it out, I guess I should have quoted him but I would appreciate help from anyone.