I'm trying to make my double jump work consistently every time you jump..
The problem I'm having is that because of gravity, velocity.y is greater as soon as you jump than it is right before you land, and the same goes for when the character is at its zenith
for example, if jumpSpeed is 600, when I apply
Addforce(0,jumpSpeed,0);
to the beginning of the jump, the characters velocity is say 50, so if you do the double jump very fast, the character goes way high
if you do the double jump right before the character touches the ground, its like nothing happens, because velocity.y is a negative value
I tried to add
currentYVelocity = rigidbody.velocity.y
rigidbody.Addforce(0,-currentYVelocity,0)
to Addforce right before I apply the new rigidbody.addforce(0,jumpSpeed,0), but this doesn't seem to do anything
I imagine there is some complicated maths that need to be done? or perhaps something in c# that already takes care of this?
Thanks for any help
↧