Search Unity

Right mouse button input

Discussion in 'Scripting' started by trickyspark, Nov 1, 2009.

  1. trickyspark

    trickyspark

    Joined:
    Apr 24, 2009
    Posts:
    121
    I'm working on a weapon that has 2 modes. When I switch to it and use mode 1 it works if I use this code:

    if
    Code (csharp):
    1. (Input.GetButton ("Fire1")
    That is the left mouse button.

    What would I put for the right mouse button?


    I can use something like:


    if
    Code (csharp):
    1. (Input.GetKey ("g")
    and there is no problem mode 2 works fine.

    I want it to do the right mouse button. I tried Getkey ("mouse2) and GetButton ("Fire2"), I'm confused as to what to put for the right mouse button using either the GetKey or GetButton.

    I can live with a key on the keyboard, the right mouse button would just be so much more comfortable.
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    What "Fire1" or whatever means is set in the Input Manager.

    --Eric
     
  3. edplane

    edplane

    Joined:
    Jul 13, 2009
    Posts:
    485
    Code (csharp):
    1. if(Input.GetButton("Fire2"));
    Thats what you should use. make sure that fire 2 is mouse 3 in the input manager (for middle mouse button).
     
  4. ybaij

    ybaij

    Joined:
    May 26, 2009
    Posts:
    3
    It must be:
    Code (csharp):
    1. Input.GetKeyDown(KeyCode.G)
    Upper.