Seeking Physics experts advice:
I have toyed around with the formulae for fixing JUMP_FORCE of my 2D platformer Character's FiniteStateMachine:
var jump_gravity: float
var jump_force: float
## Code to run when entering state
func enter_state(params: Dictionary = {}) -> void:
jump_gravity = movement_controller.gravity * movement_controller.jump_gravity_factor
jump_force = sqrt(2 * jump_gravity * movement_controller.jump_height)
controlled_body.velocity.y -= jump_force
controlled_sprite.play("jump")
...
# Somewhere in the _physics_process, I process my desired gravity for the Jump State using:
func process_gravity(delta: float, _controlled_body: CharacterBody2D, _gravity: float) -> void:
if not _controlled_body.is_on_floor():
_controlled_body.velocity.y += _gravity * delta
But i realised the issue is, whilst I can control for the jump_height very precisely, it comes at the cost of losing control over the jump air-time.
I would like to know if I can control both the Jump Height & Jump Airtime (time it takes for the Jump Force to wear off by gravity till it reaches peak of jump).
I can control for Jump_gravity and Delta in my Jump State.