From b8cdde47636649e28d9d449c1761112850eb7677 Mon Sep 17 00:00:00 2001 From: OddlyTimbot Date: Mon, 20 Oct 2025 15:42:27 -0400 Subject: [PATCH] beginning of state machine --- scripts/player.gd | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/player.gd b/scripts/player.gd index 165a0e6..5f5b65c 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -28,9 +28,16 @@ func _physics_process(delta): # As good practice, you should replace UI actions with custom gameplay actions. handle_input() handle_movement(delta) + update_states() move_and_slide() handle_collisions() - + +#Create a State Machine.........t.w. +func update_states()->void: + match current_state: + State.JUMP when velocity.y >0: + current_state = State.FALLING + func handle_input()->void: # Handle jump. if Input.is_action_just_pressed("jump") and is_on_floor(): @@ -79,8 +86,6 @@ func handle_movement(_delta)->void: if current_state == State.JUMP: #apply normal velocity velocity += get_gravity() * _delta - if velocity.y>0: - current_state = State.FALLING else: #apply hard gravity, character falling velocity += get_gravity() * hard_gravity * _delta