0 votes

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
else:
    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
    print(tripleJumpState)
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

in Engine by (14 points)

1 Answer

0 votes

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.

by (7,742 points)

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

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.