Hello, So I’m new to unity and I was watching some tutorials. I used this code on double jumping by Blackthornprod in youtube.
if (Input.GetKeyDown(“space”) && extraJumps > 0)
{
extraJumps--;
rigidbody.velocity = Vector2.up * jumpForce;
PlayerAnimator.SetBool("isJumping", true);
CreateDust();
Debug.Log("Triggered");
}
It’s working on my part but I don’t really understand it. My question is,
-
why does the variable extraJumps only decrement on the second time I jump? When I hit the space twice, the “Triggered” logs twice but the decrement only executes once.
-
As an additional problem, my isJumping bool only sets to true on the second jump as well.
-
When I add conditions in this particular if statements like && isDodging == false && isGrounded == true the second jump doesn’t work anymore
I’m sorry if this is stupid but please help me. Thank you!!!
I sent this whole post to moderation because it adds zero value to anyone, i.ncluding my own accepted answer. XD Delete?
– LilGames