Home > Net >  Why is my 2nd mouse button not detecting unity (beginner)
Why is my 2nd mouse button not detecting unity (beginner)

Time:08-16

I am trying to make a multiplayer fps game using photon and the ads is a big part. For some reason, the right mouse button is not registering, but every other one is. It works on my mouse outside of unity, but it does not work inside. My lmb is working for the ads, so I do not know why this is the case. Here is the snippet for the aim;

 }
            if (Input.GetMouseButton(2))
            {
                animator.SetBool("rmb", true);
            }
            else
            {
                animator.SetBool("rmb", false);
            }

CodePudding user response:

GetMouseButton(2) is for the middle-click button (pushing down on the scroll wheel), not the right mouse button. Use GetMouseButton(1) instead:

Small tip, you can skip the if check entirely just by passing the result of Input.GetMouseButton directly to the "rmb" parameter of the animator:

animator.SetBool("rmb", Input.GetMouseButton(1));

Documentation: Scripting API: Input.GetMouseButton

  • Related