Answer the question
In order to leave comments, you need to log in
Why does Untiy2D double jump happen?
There is actually a jump code, but if you press Space quickly, the object can make a double jump
// Код самого войда
private void OnTriggerStay2D(Collider2D collision)
{
isGrounded = true;
}
// И прыжок
void FixedUpdate()
{
if(isGrounded == true && Input.GetKeyDown(KeyCode.Space))
{
rb.AddForce(Vector2.up * jumpForce);
isGrounded = false;
}
}
Answer the question
In order to leave comments, you need to log in
In general, if you add
private void OnTriggerExit2D(Collider2D collision)
{
isGrounded = false;
}
Try swapping:
isGrounded = false;
rb.AddForce(Vector2.up * jumpForce);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question