- Home /
Question by
SugarSores · May 30, 2013 at 01:38 AM ·
upholdgetbuttondowngetbutton
Get Button and Get Button Up conflict.
Ok, so I don't know what is going wrong here. The code is pretty basic, but I just don't know why it doesn't pick up on the "Up" part. Any ideas?
function Update()
{
//Check if space is pressed.
if(Input.GetButton("Jump")){
variable = true;
}
else if(Input.GetButtonUp("Jump")){
variable = false;
}
}
Comment
Answer by robertbu · May 30, 2013 at 01:40 AM
Input.GetButton() will also be true in the same frame that GetButtonUp() is true. Because of the 'else' clause, the GetButtonUp() is check is never done. Remove the 'else', and this code should work.
Your answer
![](https://koobas.hobune.stream/wayback/20220613103158im_/https://answers.unity.com/themes/thub/images/avi.jpg)