Advanced Jump Mechanics


I wanna do a short Platformer and the jump is the main Game Mechanic
I don’t get why the Jump Height and Distance isn’t working correctly. If i set the Jump Height to 3, i should jump 3 “Blocks/Tiles” high. But the Jump Height seems also changing if i change the jump Peak time.
For Example/Jump_Hight is 3/Jump_Fall_time 0,25:
If Jump peak time is 0,3 → I jump 3 Blocks high
If Jump Peka time is 0.8 → i do a mini jump 1/4 Block high

Did anyboby why this is happening ?. I though if i race the Peak time i should jump faster

@export_category("Movement Parameters")
@export var Jump_peak_time: float = 0.27
@export var Jump_fall_time: float = 0.28
@export var Jump_height: float = 2.0
@export var Jump_distance: float = 5.0
@export var sprint_boost: float = 1.4

@export var Coyote_time:float = 0.1
@export var Jump_buffer_timer: float = 0.1

var speed: float = 5.0
var jump_velocity: float = 5.0
	#recalculate is to pixel
var pixel_jump_height:float = (16*Jump_height)
var pixel_jump_distance: float = (16*Jump_distance)

#New jump physics functions
func _ready() -> void:

func calculate_movement_parameters() -> void:
	pixel_jump_height = (Jump_height) *16
	pixel_jump_distance = (Jump_distance) *16
	jump_gravity = (2*pixel_jump_height)/pow(Jump_peak_time,2)
	fall_gravity = (2*pixel_jump_height)/pow(Jump_fall_time,2)
	jump_velocity = jump_gravity * Jump_peak_time
	speed = pixel_jump_distance/(Jump_peak_time+Jump_fall_time)
	print ("distance: " + str(pixel_jump_distance))
	print("hight: " + str(pixel_jump_height))
	print("Speed: " + str(speed))

var fully_healt: bool = false

# Get the gravity from the project settings to be synced with RigidBody nodes.
var jump_gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
var fall_gravity:float = 5.0

#Coyote Time
var jump_available: bool = true
func coyote_timeout():
	jump_available = false
#Jump Buffer
var jump_buffer = false
func jump() -> void:
		velocity.y -= jump_velocity
		jump_available = false
func on_jump_buffer_timeout() -> void:
	jump_buffer = false
func sprint():
	speed *= sprint_boost
	print("you sprint")

func _physics_process(delta: float):
	# Add the gravity.
	if not is_on_floor():
		if jump_available:
		if velocity.y>0:
			velocity.y += jump_gravity * delta
			velocity.y += fall_gravity * delta
		jump_available = true
		if jump_buffer:
			jump_buffer = false

	# Handle jump.
	if Input.is_action_just_pressed("move_jump"): 
		if jump_available:
			jump_buffer = true
	# Get the input direction and handle the movement/deceleration.
	# As good practice, you should replace UI actions with custom gameplay actions.
	var direction = Input.get_axis("move_left", "move_right")
	if direction:
		velocity.x = direction * speed
		velocity.x = move_toward(velocity.x, 0, speed)
	#handels Sprint
	if Input.is_action_just_pressed("move_sprint"):
	if Input. is_action_just_released("move_sprint"):