I am trying to create a throttle system for a player’s movement, and am binding it to the scroll wheel. My current situation is that each time the scroll wheel “clicks” it does not always register as a mouse wheel movement. I am building this off of the FirstPersonController prefab from the standard assets package. I have gotten this solved by using the Event.current system outside of OnGUI() somehow, but when I relaunched Unity it stopped working :/. Not sure how else to fix this. Writing the output of Input.GetAxis(“Mouse ScrollWheel”) just returns a random series of 0, 1, and 2.
Throttle Speed Update Function:
public void UpdateDesiredTargetSpeed()
{
float e = Input.GetAxisRaw("Mouse ScrollWheel")*10f;
if(e > 0)
{
CurrentTargetSpeed += 5f;
}
if(e < 0)
{
CurrentTargetSpeed -= 5f;
}
if(CurrentTargetSpeed >= 40f)
{
CurrentTargetSpeed = 40f;
}
Debug.Log(e);
}
The way I altered the script has it so that the CurentTargetSpeed variable is the actual speed. Any help is appreciated. As a side note, I am pretty new to unity and c# so I may be missing something obvious.