- Home /
Question by
calebbecker5 · Aug 01, 2013 at 12:00 PM ·
inputkeyboarddisabling
Need help with disabiling keyboard inputs.
function Update (){ if (Input.GetKeyDown("1")){ healthPot (); }
function healthPot (){ health += healthPotion; healthPotionAmount --; Debug.Log( healthPotionAmount + " health potion reamaining.");
}
I want to make it so when the amount of health potions reach 0, it will disable the ability to use the keyboard input, or something close to that.
Comment
Answer by Lovrenc · Aug 01, 2013 at 12:09 PM
Don't disable the ability to press key, but in your function you have to do something like:
function healthPot (){
if(healthPotionAmount > 0) {
health += healthPotion;
healthPotionAmount --; Debug.Log( healthPotionAmount + " health potion reamaining.");
} else {
//play sound or whatever to let user know there is no pots left
}
}