Godot Version
4.4.1 stable
Question
Hi guys I have a problem where I have an attack that gives you a little boost like the spin from Mario galaxy and it works 90% of the time. The other 10% the when I set the velocity.y to the jump velocity it diminishes too slow and the player doesn’t jump as high. I’m not really sure what to do now.
This is the velocity.y for when it works normally called every frame its happening
13) 0.0
-128.33332824707
-116.666664123535
-105.0
-93.3333358764648
-81.6666717529297
-70.0000076293945
-41.5201225280762
-13.0402364730835
(7) 15.4396495819092
Heres when it doesn’t go as high
(13) 0.0
-128.33332824707
-116.666664123535
-105.0
-76.5201110839844
-48.040225982666
-19.560338973999
(9) 8.91954708099365
This is how I calculate my jumps:
the code for calculating jumps is not there
oops idk why it didn’t paste im using Euler method to calculate it.
@export var jump_height : float
@export var jump_time_to_peak : float
@export var jump_time_to_descent : float
@onready var jump_velocity : float = ((2.0 * jump_height) / jump_time_to_peak) * -1.0
@onready var jump_gravity : float = ((-2.0 * jump_height) / (jump_time_to_peak * jump_time_to_peak)) * -1.0
@onready var fall_gravity : float = ((-2.0 * jump_height) / (jump_time_to_descent * jump_time_to_descent)) * -1.0
and then this in my physics process
velocity.y += get_gravity_float() * delta * gravity_scale * weight
func get_gravity_float() → float:
if velocity.y < 0.0:
return jump_gravity
elif knocked_back:
# Stop knockback if velocity is low enough
if velocity.length() < 10:
knocked_back = false
return fall_gravity
elif is_on_floor():
return 0
elif state_machine.current_state.name == “AirCombo”:
return 0
else:
return fall_gravity
sorry I just pasted it I also found out that it gets better when I increased the physics tick rate and when I set the jump height and jump_time_to_peak in physics_process but it’s still not perfect