Run And Jump

Hey guys,

This will probably be my last question towards the subject, but would someone be able to point me in the direction of how i could make a jump script, but the longer you touch the screen the higher you jump (Up until a certain height anyways) and then fall back again once the screens no longer being touched, or once the height limit has been reached.

This is a 2D run and jump game if that helps,

thanks c:

pretty much all you have to do is when you stop touching the screen apply a slight negative force downward.

So if you are using the built in 2D physics engine then just put something like

if (Input.GetButtonUp("Jump"))
{ 
             Rigidbody2D.AddForce (0, -5, 0);
}

If you want you could also do some fancy calculations to find out how fast you are travelling upwards already and apply a greater force the faster you are going. For a game I’m doing I find whatever speed I’m traveling upward, divide it by half, and then minus that from the next movement calculation.

Thanks Gale!

I’ll try it out now :slight_smile:

-Brayden