Tutorial 3.1-7 "&& isOnGround == true"
Hi there This is my first question on Unity forum. So nice to meet you all.
I have a question about tutorial.
In section 6 in tutorial 3.1, we need to add "isOnGround" in if statement as a condition in order to prevent a user from inputing Jump key, which is space, infinitely.
In if statement, it seems to have to be like this below
if (Input.GetKeyDown(KeyCode.Space) && isOnGround) // Jump statement will be executed. isOnGround = false;
Why should it NOT be like this below?
if (Input.GetKeyDown(KeyCode.Space) && isOnGround == true) // Jump statement will be executed. isOnGround = false;
I thought both functions above would work likewise-ly. But the second one does not work properly.
Thank you in advance. Tokio
They should be the same. $$anonymous$$ake sure you didn't use single-= by mistake. $$anonymous$$aybe something else changed? Otherwise, test: does it always jump, or never jump? $$anonymous$$aybe you have a completely different bug and will see both ways sometimes mess up.
Your answer
Follow this Question
Related Questions
Issue with if-statements requiring two conditions. 1 Answer
if statements are running when they are not suppose to be 1 Answer
how do i say this 1 Answer
Get Time A Bool Has Been True 4 Answers
If statement not working. 0 Answers