W
W
WasTabon2020-10-27 14:26:41
Unity
WasTabon, 2020-10-27 14:26:41

Why does the character jump all the time to different heights?

void Update()
    {
        if (Input.GetKey(KeyCode.Space) & isGrounded)
        {
            rigidbody2D.AddForce(transform.up * jumpForce, ForceMode2D.Impulse);
        }
    }


A character can jump, say, 4 unit cells, and the next jump is already 8, why is that?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DanielMcRon, 2020-10-27
@WasTabon

Let's say you pressed the space bar 2 times and during this time managed to go through 1 FixedUpdate frame, it will count it as 2 jumps

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question