Hello, how would I make this timed jump thing work

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By SomieStuff

Hi, I’m new to gdscript, and I’m starting with making a simple 2D platformer. I’m trying to make it so if you make a specific input, you can time your jump 2 more times to get a bigger jump (like “Donkey Kong 94” if you’ve ever heard of that)
First, I made a timer in the characters physics process, so I could track how many frames since the player landed, this works with no errors

if is_on_floor():
	jumpTimer = jumpTimer + 1
	jumpTimer = 0

After that, I made some if statements for the first two jumps, which work really well, and the timing works nicely.

if Input.is_action_just_pressed("Jump") and is_on_floor() and Input.is_action_pressed("Down"):
	tripleJumpState = 1
if Input.is_action_just_released("Jump")  and tripleJumpState == 1:
	tripleJumpState = 2
if Input.is_action_just_pressed("Jump") and is_on_floor() and tripleJumpState == 2 and jumpTimer < 15:
	jumpForce = jumpForce2

Now I tried to do this again with a third jump. But now the second jump will go just as high as the 3rd jump

if Input.is_action_just_released("Jump") and tripleJumpState == 2:
	tripleJumpState = 3
if Input.is_action_just_pressed("Jump") and is_on_floor() and tripleJumpState == 3 and jumpTimer < 16:
	jumpForce = jumpForce3

Any idea how to fix this would be really apprieciated

:bust_in_silhouette: Reply From: Inces

You mean first it jumps, second it jumps twice higher, and third it jumps twice higher, but it should 3 times higher ?

Are You sure it even reaches third conditions ? I don’t think it is so easy to press frame-perfect input twice in a row heheh. Print something there to make sure. I bet it just stays jumpstate2.

If somehow You menage to make that input, maybe the problem lies with your jumpforce variables and the way vertical velocity handles it ? Post this piece of code please.

Oh, I just placed the frame-perfect thing as a testing thing so the third one doesn’t work, it doesn’t work with the original timing

SomieStuff | 2022-02-05 00:18

Ok, so print jumpstate every time You make a jump so You will know where is the problem. Post a code with introducing jumpforce variable and using them for actual movement

Inces | 2022-02-06 08:56