How can i make an if statement fire only when the player doesn't hit a button?
Hi! I am making a stamina mechanic in my game and I need to make a if statement that says to the game if the player has less stamina than the int in void start and the player doesn't hit shift it should regenerate it. And I have almost everything figured out but the part where the player is not allowed to use the input shift (I have a line in the code that says if the stamina hits 0 shift is blocked what I mean by not allowed that if he presses it he can still run but stamina will not regenerate) ,
Answer by chor64 · Jun 01, 2020 at 11:06 PM
Use the "!" before your button check (It basically means "not") . You could also use the "else" statement.
For example:
if (!"button check here")
{
//Regenerate stamina
stamina += "regeneration speed" * Time.deltaTime;
//Limit the stamina
stamina = Mathf.Clamp(stamina, "minimum stamina here", "maximum stamina here");
}
Your answer
Follow this Question
Related Questions
reloading Greater Than or Equal To c# 0 Answers
If an integer ends with an 1. 1 Answer
I am trying to close the GUI if its already active and the user clicks 0 Answers
Word guessing game 1 Answer
Relevant GameObject[]. 1 Answer