-
Jump button?
How can I make my character be able to jump?
-
Senior Member
Re: Jump button?
Are you using a custom object (like a stack of tires or the sphere) or the actual rider like I am? 
You can attach a Directional Force to it, give something powerful like 1000 and set Enabled to Unchecked.
Next go like this:
[code:2g7zqx91]Button Y (or whatever) PRESS
State ON - Directional Force
State OFF - Button Y
Impulse Delay 0.1 or 0.2 (this is how long it takes to jump up)
State OFF - Directional Force
Delay (approximate time to reach the ground)
State ON - Button Y
[/code:2g7zqx91]
So you press Y, the Force lifts the character into the air, then a short bit later gravity takes effect and the character drops back down. You have to disable the button or add that thing that limits the number of Impulses sent in a period of time else the player can just mash the jump button to fly through the air!
You can also use an Area Force (Effector?) set to only affect the object that is jumping, but it's the same code. You could however use the Area Effector to lift other objects around the character, like if his jumping sent off a shockwave that send objects flying away from its center 
Rather than have the Jump command wait a time before becoming active again, you can use a Hit Trigger to detect when the character is not in the air. Then you can jump from different heights and up stairs.
[code:2g7zqx91]Hit Trigger:
Target 1 - Include Character
Target 2 - Include Ground, Static, Dynamic (does dynamic include itself or the physics joint as well?)
ACTIVE > Set Value to 1
INACTIVE > Set value to 0
Button Y PRESS > Generic Filter
IF Value = 1 TRUE (If character is touching the ground or a static object, i.e. CAN jump)
State ON - Directional Force
Impulse Delay (to disable the jump momentum)
State OFF - Directional Force
FALSE (For good measure)
State OFF - Directional Force[/code:2g7zqx91]
You can also use Button Y RELEASE to trigger the State OFF early to make your character jump lower if pressed briefly (like in Super Mario).
*NOTE* You will need to give your character 'feet' unless you want them to be able to jump while touching the ceiling or walls.