Search Unity

How to use same Axis Control values for all Free Look vcams in State Driven Camera

Discussion in 'Cinemachine' started by nisliorc, Jul 17, 2018.

  1. nisliorc

    nisliorc

    Joined:
    Jun 28, 2018
    Posts:
    3
    At the State Driven Camera, when animator switch from one FreeLook vcam to another FreeLook vcam, it seems that the Axis Control values are not shared. So every time vcams switched, it also switch between different camera orbits and angles (return to previous Axis values it was using before it was last disabled). I want to use same Axis Control values for both states so the vcam switch would be smoother.

    Anyone know if there any easy way to do it?
    Thanks,
    Orcun.
     
  2. nisliorc

    nisliorc

    Joined:
    Jun 28, 2018
    Posts:
    3
    Ok, I found the source of my issue. On my Free Look states the Follow game object have different targets. I found that there is a conditional check in CinemachineFreeLook.OnTransitionFromCamera method, that only synchronize Axis Control values if the Follow targets are the same. When I removed that condition, it began to work correctly.

    Code (CSharp):
    1.         public override void OnTransitionFromCamera(
    2.             ICinemachineCamera fromCam, Vector3 worldUp, float deltaTime)
    3.         {
    4.             base.OnTransitionFromCamera(fromCam, worldUp, deltaTime);
    5.             if ((fromCam != null) && (fromCam is CinemachineFreeLook))
    6.             {
    7.                 CinemachineFreeLook freeLookFrom = fromCam as CinemachineFreeLook;
    8.                 // Temporary Hack
    9.                 //if (freeLookFrom.Follow == Follow)
    10.                 {
    11.                     m_XAxis.Value = freeLookFrom.m_XAxis.Value;
    12.                     m_YAxis.Value = freeLookFrom.m_YAxis.Value;
    13.                     UpdateCameraState(worldUp, deltaTime);
    14.                 }
    15.             }
    16.         }