Search Unity

Resolved Cinemachine Freelook instant rotation

Discussion in 'Cinemachine' started by Eg1l, Mar 22, 2022.

  1. Eg1l

    Eg1l

    Joined:
    Sep 28, 2015
    Posts:
    11
    Hello!
    I am trying to do an instant rotation on a CinemachineFreeLook rig. This is so that I can achieve a "hard cut" where the camera is rotated to a new angle.

    The x axis seems to respond immediately, but setting the Y axis (which prefer a value between 0-1) seems to take one or more frames to procedurally find its pitch position.

    Code (CSharp):
    1.  
    2. // This seem to work immediately
    3. AnchorCamera.GetComponent<CinemachineFreeLook>().m_XAxis.Value = Vector3.SignedAngle(Vector3.forward, forward, Vector3.up);
    4.  
    5. // This will take effect one frame later
    6. AnchorCamera.GetComponent<CinemachineFreeLook>().m_YAxis.Value = .5f;
    Looking at the code, the method ForceCameraPosition(position, rotation); could be useful here, but that leaves me having to calculate the end position in the freelook orbit first.

    Is there a way for me to have the procedural Y orbital position to be calculated immediately?
    Or similarly, is there a way to get a suggested orbital position that can be used in conjunction with ForceCameraPosition?
     
  2. Eg1l

    Eg1l

    Joined:
    Sep 28, 2015
    Posts:
    11
    I could also add to this that I do not use any damping on Aim and Body
     

    Attached Files:

  3. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    Try setting freeLook.PreviousStateIsValid=false. Then you can keep the damping.
    EDIT: oh, sorry. Misread your previous post. Try adding that anyway and tell me if it helps.
     
  4. Eg1l

    Eg1l

    Joined:
    Sep 28, 2015
    Posts:
    11
    Thanks Gregory for the quick reply. Unfortunately this didn't fix it. Had to do some recordings and study frame by frame. The new Y axis still is delayed by at least one frame.
     
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    I don't understand why you have the delay. I'd have to look into the code, which I'm not free to do right now. As a quickie experiment, try calling freeLook.InternalUpdateState() after you set the axis values. Maybe that will do it.
     
  6. Eg1l

    Eg1l

    Joined:
    Sep 28, 2015
    Posts:
    11
    Calling freelook.InternalUpdateCameraState(Vector3.up, -1); seem to have solve it!
    Note that it did not work when sending deltaTime with a value higher than 0. I am curious to why this happens?
     
    Gregoryl likes this.
  7. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    deltaTime = -1 implies a PreviousState reset, eliminating damping.