- Home /
Jump higher when held button
Hi guys,
In games like Mario, if you hold the jump button, you jump higher, allowing for a better platforming experience. I tried accomplishing this, but couldnt figure out how. I use AddForce, and tried lowering the mass if the button was held, but this didn't work. Can anyone help?
Thanks.
That is quite a tricky question if we don't have any code! Could you please post the code in either a comment or an edit
Answer by robertbu · Aug 07, 2013 at 07:24 PM
If you are using a rigidbody (as you've indicated by your reference to 'AddForce'), then in addition to the major force you apply when you first jump, you can add a very small amount of additional force each frame while the button is held down. If you don't want that force to be applied when the character is falling, then you can check to make sure the 'rigidbody.velocity.y' is positive before adding the small amount of force.
That's a fine idea, I'll see if it works :)
Edit: It worked! Thanks mate :) Thanks also to Lucas$$anonymous$$ars for the interest
Your answer
