The question is answered, right answer was accepted
if (input.Getkey(Keycode) returns true forever after pressing the key once?
Is this a bug in unity 2019?
void LateUpdate()
{
if (Input.GetKey(KeyCode.LeftShift)) { boostAxis = 1; }//speed up
}
if you press shift, this if statement returns true forever. However using the input manager:
void LateUpdate()
{
boostAxis = Input.GetAxis("boost buttons"); //speed up
}
only returns true while the button is held. Is there a way to make "GetKey" work the same way as "GetButton" or "GetAxis" and return true only while held?
Answer by Hellium · Feb 13, 2021 at 10:08 AM
You simply need an else { bootAxis = 0; }
, don't you?
Basically. I had a brainfart, it just that "GetAxis" returns 0 by default with no input, while GetKey doesn't. Dunno why i thought it did.
Follow this Question
Related Questions
How do I save separate keycodes presses at same time and store for use later in update? 0 Answers
input.getkey keycode scrollwheel - Is this even possible? 0 Answers
Using one key only, change bool to true or false depending on it's current value 2 Answers
Change Input.GetKey to Input.GetAxis 1 Answer