4
\$\begingroup\$

I am trying to make a simple weapon change in Unity3D. The best way to do this is with the mouse scroll wheel, as far as I can see.

I googled on how to do this and found that I have to use Input.GetAxis("Mouse ScrollWheel"); I use this piece of code and print it. Still, I always get an value of 0. any ideas? I just need to solve how to get the value first, I'll figure out the rest myself.

Code idea:

function Update () {
    print(WeaponNumber);

    if(Input.GetAxis("Mouse ScrollWheel")){
    WeaponNumber += Input.GetAxis("Mouse ScrollWheel");
    }
}
\$\endgroup\$
3
\$\begingroup\$

In addition to using the code you have above you need to configure the axis in the input manager and name it correctly.

The accepted answer here may be of help: http://answers.unity3d.com/questions/6106/implementing-the-scrollwheel

\$\endgroup\$
  • \$\begingroup\$ @BallzOfSteel, if you are satisfied with an answer, please click the accept answer button. \$\endgroup\$ – AttackingHobo Apr 27 '11 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.