Skip to content

Issue with calculate jump velocity?


func _calculate_jump_velocity(_jump_height: float = jump_height, time_to_peak: float = jump_time_to_peak) -> float:
	return 2.0 * max(0, _jump_height / (time_to_peak * actor.up_direction.y))
  • Godot 4.2.1
  • MotionComponent2D from the repository directly

Given that by default Jump Height is positive and up_direction is -1, doesn't this only ever return 0? Playing with the project I was unable to get this to work given the defaults in 2D. Was there something I was missing in proper use of these functions, or should that really be min rather than max.

Edited by zaknafean