Character - Double Jump (SOLVED)

19 October 2016 03:03
Hello B4W team!

Do you have any suggestions for programming a 'double jump'.

If I hit space again while the character is in a current Jump I want him to jump again in the air.

I'm using this sensor and function:

var jump_cb = function(_character, id, pulse) {
m_ctl.create_sensor_manifold(_character, "JUMP", m_ctl.CT_SHOT, [key_space], null, jump_cb);
22 October 2016 01:43
I'm not sure but there is a part of the manifold that is called logic. It should return True for the callback to trigger. Maybe you can have two True logic outputs from that function.
Something like three states or what 0 can jump return's true state = 1, if state equal 1 returns true again, state = 2. f state equal 2 returns false. When you land state =0 again.
Maybe not the best idea but could probably work.

Best regards
22 October 2016 06:43
Thanks Luke, good idea I'll try it out!
23 October 2016 13:07
Great ! I was not sure that would help. I struggle with these manyfolds myself. But the api describes quite well what every argument in the function should be. There is also an example in the documentation that is quit helpful to get an idea of what is going on !

MAYBE ? You could use two manifold with different logics.
something that return true when the key down && not jumping
a second for double jump that returns true only if key down && jumping.
That way your two callbacks can be different if you don't want the exact same jump when you double jump.

Thats only as far as i understand. But thats what i understand from the game tutorial.
25 October 2016 19:46
Hey Luke, thanks for the additional info!

I found a simple way to get double jump. Use physics velocity instead of character controls for jump!
Once the spacebar is hit twice don't allow any more jumps until the character collides with the ground and reset the counter.

So the code for the sensors I get pretty well now after playing around with them unfortunately.. the documentation on how to set up the .blend file with physics and the collisions is lacking. Maybe I did something silly but can't get the example to work.

I made a new post about collision detection & sensors

almost there! ;)

thanks again
26 October 2016 07:21
After 2 jumps don't allow any more force to be applied in the Z direction until a collision with the ground occurs, the reset the jump counter ;).

Still no luck with the material special collision but using just the collision ID on the physics panel worked so I got my double jump.

Another problem showed up, if I enable the 'Character' checkbox on the physics panel the regular collision stops working again.
Please register or log in to leave a reply.