Search Unity

How can I disable mouse axis input on FreeLook camera?

Discussion in 'Cinemachine' started by GIitch, Jan 5, 2019.

  1. GIitch

    GIitch

    Joined:
    Aug 1, 2013
    Posts:
    24
    I'm using WASD to move the camera and having the mouse affect it just causes too many issues for my project's camera perspective. How can I disable mouse axis input? Edit: Figured it out but I have no idea how to delete a post.

    Under Axis Control in the Cinemachine Inspector, remove 'Mouse Y' and 'Mouse X' under Input Axis Name.
     
    Last edited: Jan 5, 2019
    Gregoryl likes this.
  2. BladeManEXE10

    BladeManEXE10

    Joined:
    Mar 21, 2019
    Posts:
    20
    Or if you want it to be enabled when you're holding down the right mouse button... (Not sure if being in Update or FixedUpdate makes a difference.)

    Code (CSharp):
    1. using UnityEngine;
    2. using Cinemachine;
    3.  
    4. public class Script_Name : MonoBehaviour
    5. {
    6.  
    7.     public CinemachineFreeLook cameraLook;
    8.  
    9.     private void FixedUpdate()
    10.         {
    11.             if (Input.GetMouseButton(1))
    12.             {
    13.                 cameraLook.m_YAxis.m_InputAxisName = "Mouse Y";
    14.                 cameraLook.m_XAxis.m_InputAxisName = "Mouse X";
    15.             }
    16.             else
    17.             {
    18.                 cameraLook.m_YAxis.m_InputAxisName = "";
    19.                 cameraLook.m_XAxis.m_InputAxisName = "";
    20.             }
    21.         }
    22. }