- Home /
Question by
lancer · Aug 28, 2013 at 10:05 PM ·
javascriptmouse
Detecting Mouse Scroll Wheel?
I'm tying to make it so that when I scroll with the mouse wheel in moves the transform that the script is attached too forward and backward. How can I do this? I'm using Unity Free and JavaScript.
Comment
Best Answer
Answer by clunk47 · Aug 28, 2013 at 10:12 PM
#pragma strict
function Update ()
{
transform.Translate(Vector3.forward * Input.GetAxis("Mouse ScrollWheel"));
}
Answer by DESTRUKTORR · Aug 28, 2013 at 10:11 PM
Input.GetAxis("Mouse ScrollWheel")
gets the scroll wheel's input (returns a number representing the speed and direction that it is being spun, as a float).
Your answer
Follow this Question
Related Questions
trying to move an object with the mouse 1 Answer
Mouse Click To World Pos 2 Answers
How to detect double and single clicks using javascript? 1 Answer
Invert mouse control 2 Answers
Move at mouse click 0 Answers