- Edited
I have a problem with my double jump system. I want it to work so if you didn't jump on a platform before double jumping, you can't double jump. I have failed horribly over 2 days to make it work and would be extremely happy if you could tell me how I could solve my problem.
Here is the code:
func _physics_process(delta):
if !is_on_floor():
coyote_time()
velocity.y += gravity * delta
if is_on_floor():
if jumpWasPressed:
velocity.y = JUMP_VELOCITY
jumpAfterLeavingPlatform = true
if Input.is_action_just_pressed("up"):
jumpWasPressed = true
remember_jump_time()
anim.play("Flap")
if Global.pickup == 1:
canDoubleJump = true
if jumpAfterLeavingPlatform == true:
velocity.y = JUMP_VELOCITY
if Input.is_action_just_pressed("up") and !is_on_floor() and canDoubleJump and !Global.pickupTimer:
anim.play("Flap")
velocity.y = JUMP_VELOCITY
Global.pickupTimer = true
canDoubleJump = false