Hey, I am trying to get something to count when I move my mouse wheel. So when I move my mouse wheel foward it will count up and when I move it back it will count down. I also would like set the number limit from 1 to 5. Need the number of wheel turns to be in a variable so I can use it in if statements.
using UnityEngine;
using System.Collections;
public class ScrollCounter : MonoBehaviour
{
public int whateverNumber = 1;
// Update is called once per frame
void Update ()
{
if (Input.GetAxis("Mouse ScrollWheel") > 0) // forward
{
whateverNumber = whateverNumber + 1;
}
else if (Input.GetAxis("Mouse ScrollWheel") < 0) // back
{
whateverNumber = whateverNumber - 1;
}
}
}
I think you can and should figure the rest out for yourself
using UnityEngine;
using System.Collections;
public class ScrollCounter : MonoBehaviour
{
public int whateverNumber = 1;
// Update is called once per frame
void Update ()
{
if (Input.GetAxis("Mouse ScrollWheel") > 0) // forward
{
whateverNumber = Mathf.Clamp(whateverNumber++, 1, 5);
}
else if (Input.GetAxis("Mouse ScrollWheel") < 0) // back
{
whateverNumber = Mathf.Clamp(whateverNumber--, 1, 5);
}
}
}