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.
#pragma strict
function Update ()
{
transform.Translate(Vector3.forward * Input.GetAxis("Mouse ScrollWheel"));
}
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).