Hi i have this simple script:
if (Input.GetKeyDown(KeyCode.Space))
{
Debug.Log("1");
}
else
{
Debug.Log("0");
}
Its should write 1 when the space bar is pressed and 0 when not pressed. But it just writes “0” What am i doing wrong?
First, if you post a code snippet, ALWAYS USE CODE TAGS:
How to use code tags: Using code tags properly
Go read the docs for Input.GetKeyDown()
- it has to be used in Update()
- it only returns true on the one single frame that the key goes down.
Are you looking for Input.GetKey()
perhaps?
Thanks for the advice i know relise how stupid it was to use GetkeyDown thanks a ton!