- Home /
Scroll input carrying over to next scene
I'm using Input.GetAxis("Mouse ScrollWheel") for a mechanic of zooming in and out in my game. In one scene, zooming all the way out loads a new scene. The problem is this scrolling carries over into the next scene. To be specific, scrolling loads a new scene and then even if you stop scrolling while the next scene is loading, the scrolling (and therefore zooming) continues at the start of the next scene. I've tried using Input.ResetInputAxes() before and after loading the next scene and at the beginning of the next scene, but none of this prevents the input from carrying over.
Right now, my solution is hacky. I have a boolean that simply prevents input from being taken for the first couple seconds of the next scene, but this is a little annoying for the player so I would like to avoid it if possible. Does anyone have any ideas of how to solve this problem or what may be going wrong?
Thank you!
It may help to see some code. What conditions need to be met in order for the scene to load? I assume they are reset before the new scene is loaded? x] You say even if you stop scrolling it continues, so maybe you need to make sure the player is providing the input?: if(Input.GetAxis("$$anonymous$$ouse ScrollWheel") != 0) { //scroll }
The code for zoo$$anonymous$$g varies by scene, so my code isn't super relevant. Input.GetAxis ("$$anonymous$$ouse ScrollWheel") should return 0f when the player is not scrolling, so it's very strange that it is not doing so.
//Scene 1:
float size = $$anonymous$$athf.Clamp((text.rectTransform.localScale.y + (Input.GetAxis ("$$anonymous$$ouse ScrollWheel")/12.5f)), 0f, startSize);
text.rectTransform.localScale = new Vector3 (size, size, size);
if (text.rectTransform.localScale.y < 0.01f) {
Input.ResetInputAxes ();
text.gameObject.SetActive (false);
Scene$$anonymous$$anager.LoadScene ("$$anonymous$$ain");
}
//Scene 2:
float fov = cam.fieldOfView;
fov -= Input.GetAxis("$$anonymous$$ouse ScrollWheel") * sensitivity;
fov = $$anonymous$$athf.Clamp (fov, $$anonymous$$FOV, maxFOV);
cam.fieldOfView = fov;
does it work if you call Input.ResetInputAxes (); when the scene loads, rather than before loading the next scene? It's possible the inputs are still being registered after the LoadScene call