Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How to make Free Look camera stop tracking Mouse movements when holding button.

Discussion in 'Cinemachine' started by Zadik, Oct 21, 2020.

  1. Zadik

    Zadik

    Joined:
    Oct 1, 2020
    Posts:
    6
    I want my free look camera to stop rotating when Im holding shift, but still follow the player.
    Then go back to a Free look camera when I let go of shift.

    I tried doing some shenanigans with switching between seperate cameras, but I couldn't get the correct results.
     
    Last edited: Oct 21, 2020
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,153
    Shenanigans with switching between separate cameras is probably the right approach. You just need the right shenanigans. What did you try and how was it wrong?
     
  3. Zadik

    Zadik

    Joined:
    Oct 1, 2020
    Posts:
    6
    I had my free look camera, and a normal virtual camera which I set the position to the freelook camera every frame. It almost worked but the camera would either reset back to its original position when I switched, or it would fly off into the distance for whatever reason. The best I got was where it would track the player, but not follow. which is the opposite of what I want. It just felt like there was 1 setting I was missing.
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,153
    Can you show me the inspectors for the FreeLook and the other vcam? You can paste images directly into the forum post.
     
  5. Zadik

    Zadik

    Joined:
    Oct 1, 2020
    Posts:
    6
    The freelook
    upload_2020-10-22_13-21-7.png upload_2020-10-22_13-21-27.png upload_2020-10-22_13-21-43.png
    The vcam
    upload_2020-10-22_13-22-47.png
     

    Attached Files:

  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,153
    Try enabling this in both cameras:

    upload_2020-10-22_14-25-28.png
     
  7. Zadik

    Zadik

    Joined:
    Oct 1, 2020
    Posts:
    6
    It almost worked! but now the vcam is slowly spinning until it spirals out of control
     
  8. Zadik

    Zadik

    Joined:
    Oct 1, 2020
    Posts:
    6
    I got it working thanks for the help = )
     
    Gregoryl likes this.
  9. mite51

    mite51

    Joined:
    Jun 25, 2015
    Posts:
    23
    This worked ok for me...

    void Update()
    {
    if (Input.GetKeyDown(KeyCode.LeftControl ) )
    {
    vcam.m_XAxis.m_InputAxisName = "Mouse X";
    vcam.m_YAxis.m_InputAxisName = "Mouse Y";
    }
    else if (Input.GetKeyUp(KeyCode.LeftControl))
    {
    vcam.m_XAxis.m_InputAxisName = string.Empty;
    vcam.m_YAxis.m_InputAxisName = string.Empty;
    }
    }