June 2018
Beginner to intermediate
298 pages
7h 38m
English
Double-jumps are a popular platforming feature. The player gets a second, usually smaller, upwards boost if they press the jump key a second time while in the air. To implement this feature, you need to add a few things to the player script.
First, you will need two variables to track the state:
var max_jumps = 2var jump_count = 0
When entering the JUMP state, reset the number of jumps:
JUMP: new_anim = 'jump_up' jump_count = 1
Finally, in get_input(), allow the jump if it meets the conditions:
if jump and state == JUMP and jump_count < max_jumps: new_anim = 'jump_up' velocity.y = jump_speed / 1.5 jump_count += 1
Note that this makes the second jump 2/3 the upward speed of the normal jump. You can adjust this according to your ...
Read now
Unlock full access