- Home /
How can I check if a key/button is not (!) being held down?
I have a simple check for GetButtonUp and I would like to add a check to make sure another button is not being held down at the same time. For example, when the "W" button is released & the "A" button is NOT being held down (GetButton), then do something. I've tried adding a "!" infront of Input.GetButton but that doesn't seam to do anything:
if (Input.GetButtonUp("Walk") && !Input.GetButton("WalkLeft")) {
//do something
}
So how could I do this simple functionality?
Thanks for confir$$anonymous$$g that, I thought so as well but I wanted to double check to make sure because the functionality wasn't working as expected. Luckily the problem was elsewhere! If you'd like to convert your comment to an answer I can mark it as accepted ;)
Answer by GameVortex · Jan 29, 2014 at 08:10 AM
What you have there is the correct way of checking if the button is not being held down. Have you made sure the "WalkLeft" input is set up properly in the Input settings? Try testing with just "WalkLeft" and nothing else to make sure it works.