U
U
Uncle Bogdan2021-09-17 22:13:16
Unity
Uncle Bogdan, 2021-09-17 22:13:16

How to make a jump that is independent of the current speed?

I decided to make a clone of Doodle jump and ran into a problem that the player sometimes (rarely, but an eyesore) jumps "half a ball" (not completely, but about half). How can I replace AddForce for my task? Or is it the norm?

Here is the code:

public void Jump()
    {
        _rigitbody.AddForce(Vector2.up * _jumpForce, ForceMode2D.Impulse);
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Boronnikov, 2021-09-20
@motkot

_rigitbody.AddForceadds another vector of force applied to the object. The final movement occurs under the resultant forces.
In other words, when you throw on Vector2.up * _jumpForcethe resultant force will not only be directed upwards if another force was added somewhere on the body. Those. According to your description, everything looks like that somewhere on the body there is a downward force of gravity, which is approximately equal to the force that you are trying to lift up. And because he does not move at all or barely moves

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question