Hi,
I’ve got some problems with an input value.
When pressing the left mouse button my character should shoot. This works fine except in one case.
When putting this in my update function:
Debug.Log( Input.GetMouseButton( 0).ToString());
It says that the button is not held down for 3 frames and then it returns true until i press the button and release it.
Input.resetInputAxes does not have any effect…
My boss has a poor computer and I’ve noticed this lag on her machine as well (where all the input commands are lagging behind). Reducing the rendering quality helped aleviate it though.
Try dropping your quality settings to minimum and see if that changes anything.
When you use GetMouseButton(), it’s checking to see if the mouse button is currently down. Since our human hands aren’t capable of pressing for exactly one frame, it registers for three frames. The one you probably want is Input.GetMouseButtonDown() which detects if the mouse button changed from up to down during that frame.
The same applies for GetKey() and GetKeyDown().
Maybe it’s just me, but I think the terms are a little backward. You would think that GetMouseButtonDown would say whether or not it’s down. Maybe GetMouseButtonIsDown()? and the other GetMouseButtonPressed()?