- Home /
Key Press Queuing
I've noticed when I use C# code to move a game object in response to a keypress, that holding the key down for a few seconds nonstop causes the object to continue moving for a moment after I release the key.
Alternatively, if I just jab the keys quickly, the object starts and stops instantly.
Is this some kind of key queuing and can it be disabled?
Here's the basic code I used to do the move (Spuddie is just a sphere with "arms" along it's axes):
public class SpuddieMover : MonoBehaviour { public GameObject Spuddie;
private void Update()
{
float z = Input.GetAxis("Vertical");
if ( z > 0)
Spuddie.transform.Translate(Spuddie.transform.up * Time.deltaTime);
else if (z < 0)
Spuddie.transform.Translate(Spuddie.transform.up * Time.deltaTime * -1);
}
}
Thanks in advance for any help! :)
Nice insight! I tried this, but I still get queued actions too.
I have my player shooting his gun.. if I press the shoot button quickly in sequence. The gun will shoot and wait for the animation to finish, then shoot again. This is well past 1 second of letting go of the key.
Any other suggestions would be greatly appreciated @ $$anonymous$$aulkye
Answer by Eric5h5 · Aug 06, 2010 at 12:32 AM
Go to the input manager and change the gravity and sensitivity for the axis as desired.
I tried setting both to 0, but it seems to have no effect. :(
Note that my sphere is not a rigid body, so I wouldn't think gravity would have any effect... would it?
Also, isn't sensitivity was just for joysticks, mice, or other devices with ranged input?
Thanks
@$$anonymous$$aulkye, gravity in the input manager settings has nothing to do with rigidbodies, it's about the input settings. And no, sensitivity is not just for mice, it's for keyboards. http://unity3d.com/support/documentation/Components/class-Input$$anonymous$$anager.html
Ah thanks, I see it now. $$anonymous$$uch appreciation for your patience.
Your answer