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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Resolved Turning off the panning when moving

Discussion in 'Cinemachine' started by dasAndy, Mar 6, 2022.

  1. dasAndy


    Jun 3, 2019
    Hello there

    I have built a top view camera using cinemachine.

    I want the camera to look at the player from above. If you zoom in with the middle mouse button, the camera comes a bit lower behind the player. If you keep the right mouse button pressed, you can rotate the camera around the player.

    This behavior can be done very well and very fine adjustable by cinemachine. For this I used a free look camera with binding on wolrd space and I wrote my own modifiers for the input axes.

    Code (CSharp):
    2.     void Start()
    3.     {
    4.          CinemachineCore.GetInputAxis = GetInputAxis;
    5.     }
    7.     private float GetInputAxis(string axisName)
    8.     {
    9.         if (axisName == "Mouse Y")
    10.         {
    11.             if (Input.GetMouseButton(2))
    12.             {
    13.                 return Input.GetAxis("Mouse Y");
    14.             }
    15.             return 0f;
    16.         }
    18.         if(axisName == "Mouse X")
    19.         {
    20.             if (Input.GetMouseButton(1))
    21.             {
    22.                 return Input.GetAxis("Mouse X");
    23.             }
    24.             return 0f;
    25.         }
    27.         return Input.GetAxis(axisName);
    28.     }
    Everything works the way I want it to. Almost.

    When the player moves, there is always a little panning like rotation of the camera. I made a short video (from second 00:10) so you can see what I mean. I could't find a way to turn off this behavior. Can someone maybe help me with this?

  2. dasAndy


    Jun 3, 2019
    By playing around even more, I figured it out myself.
    The damping values for aim and body control this behavior. If I set the values for movement and rotation to 0, the camera is absolutely fixed above the player. If I set the values not equal to 0 but still all equal to each other, the camera still moves very smoothly but the annoying rotation is gone.

    Thanks fpr reading anyway ;)
    antoinecharton and Gregoryl like this.