Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » infinite jumps
- Ausername57
-
100+ posts
infinite jumps
anyone know how to fix my games jumping? i want to make a double jump and i dont want it to jump infinite amounts of times. does anyone know how to fix this?
game: https://scratch.mit.edu/projects/1128791351/
game: https://scratch.mit.edu/projects/1128791351/
- Orange_Proto
-
25 posts
infinite jumps
if <[Jumps] < [2]> then
change [Jumps v] by (1)
Jump
end
This may work, I already tested the code in a project.
- Catscratcher07
-
1000+ posts
infinite jumps
Make a variable keeping track of the number of jumps the player has and set it to 2 whenever they touch the ground. Whenever they press the jump button, first check that the variable is greater than zero, and only if it is do your jumping script and subtract one from the variable. You will also need to program a delay after the player jumps in which they can't jump again, otherwise the player would have to press jump for just a single frame to avoid wasting their double jump.
- Ausername57
-
100+ posts
infinite jumps
dosent work, can you give me the code for it? Make a variable keeping track of the number of jumps the player has and set it to 2 whenever they touch the ground. Whenever they press the jump button, first check that the variable is greater than zero, and only if it is do your jumping script and subtract one from the variable. You will also need to program a delay after the player jumps in which they can't jump again, otherwise the player would have to press jump for just a single frame to avoid wasting their double jump.
- Catscratcher07
-
1000+ posts
infinite jumps
Jump should be in the forever loop with the other movement handling custom blocks, and should not have forever or any waits. (NEVER put forever or waits in a “run without screen refresh” custom block") Before setting y speed, run this if:dosent work, can you give me the code for it? Make a variable keeping track of the number of jumps the player has and set it to 2 whenever they touch the ground. Whenever they press the jump button, first check that the variable is greater than zero, and only if it is do your jumping script and subtract one from the variable. You will also need to program a delay after the player jumps in which they can't jump again, otherwise the player would have to press jump for just a single frame to avoid wasting their double jump.
if <<(jump tracker) > [0]> and <[last jump] > [x]>> then //you can name last jump whatever you want, and x is a number to be determined by trial and errorafter set y speed, set last jump to 0, at some other point in you game loop, change it by one.
end
Changing jump tracker by one should be done in your floor detection if.
- Discussion Forums
- » Help with Scripts
-
» infinite jumps