Variable jump height turned into double jump when I didnt want to

Godot Version :

v4.7.2.

Question

Hello! I’m four days into learning Godot and i’ve been relying a lot on tutorials
For my warmup project i’ve been trying to learn Super Mario bros mechanics, but instead of my player jumping with a variable jump height, my penguin is doing double jumps!

I’m using state machines to control his movement, but I have no idea how to fix the mistake

VideoProject11-ezgif.com-video-to-gif-converter Gravando2026-09-23205144-ezgif.com-video-to-gif-converter

enum PlayerState{
[...]
jump,
fall
[...]
}

[...]
const gravity: float = 15.5
const jump_height: float = -265
const var_jump_threshold: float = jump_height + 100

var var_jump_applied: bool = false
var release_jump_key: bool = false
var status: PlayerState

[...]

func _physics_process(delta: float) -> void:
	
	if not is_on_floor():
		velocity += get_gravity() * delta
[...]
    match  status:
		PlayerState.jump:
			jump_state(delta)
		PlayerState.fall:
			fall_state(delta)

[...]
func go_to_jump_state():
	status = PlayerState.jump
	anim.play("jump")
	var_jump_applied = false
	release_jump_key = false
	velocity.y = jump_height
func go_to_fall_state():
	status = PlayerState.fall
	anim.play("Fall")

[...]
func jump_state(delta):
	move(delta)
	if velocity.y > 0:
		go_to_fall_state()
		return
func fall_state(delta):
	move(delta)
	if !release_jump_key and !Input.is_action_just_pressed("jump"):
		release_jump_key = true
	if release_jump_key and !var_jump_applied and velocity.y < 0.0  and velocity.y > var_jump_threshold:
		go_to_idle_state()
		velocity.y *= 0.5
		var_jump_applied = true
	else: go_to_walk_state()
	return


It seems like your fall state always progresses to walking or idle states, wouldn’t that allow another jump? Should you only progress to a floor-state when is_on_floor() is true?