|
@ -27,8 +27,8 @@ func _physics_process(delta: float) -> void: |
|
|
is_crouching = Input.is_action_pressed("crouch") |
|
|
is_crouching = Input.is_action_pressed("crouch") |
|
|
|
|
|
|
|
|
apply_gravity(delta) |
|
|
apply_gravity(delta) |
|
|
handle_jump() |
|
|
|
|
|
handle_running() |
|
|
|
|
|
|
|
|
handle_jumping() |
|
|
|
|
|
set_is_running() |
|
|
handle_movement() |
|
|
handle_movement() |
|
|
handle_crouching(delta) |
|
|
handle_crouching(delta) |
|
|
|
|
|
|
|
@ -60,7 +60,7 @@ func handle_crouching(delta: float) -> void: |
|
|
else: |
|
|
else: |
|
|
pass # Continue crouching until nothing overhead |
|
|
pass # Continue crouching until nothing overhead |
|
|
|
|
|
|
|
|
func handle_jump() -> void: |
|
|
|
|
|
|
|
|
func handle_jumping() -> void: |
|
|
if not Input.is_action_just_pressed("jump"): return |
|
|
if not Input.is_action_just_pressed("jump"): return |
|
|
if not is_on_floor(): return |
|
|
if not is_on_floor(): return |
|
|
velocity.y = jump_velocity |
|
|
velocity.y = jump_velocity |
|
@ -87,7 +87,7 @@ func handle_movement() -> void: |
|
|
## Running is disabled when:[br] |
|
|
## Running is disabled when:[br] |
|
|
## 1. The `run` input is pressed (ie toggled)[br] |
|
|
## 1. The `run` input is pressed (ie toggled)[br] |
|
|
## 2. Is no longer moving |
|
|
## 2. Is no longer moving |
|
|
func handle_running() -> void: |
|
|
|
|
|
|
|
|
func set_is_running() -> void: |
|
|
if Input.is_action_just_pressed("run") and not is_running: |
|
|
if Input.is_action_just_pressed("run") and not is_running: |
|
|
is_running = true |
|
|
is_running = true |
|
|
elif Input.is_action_just_pressed("run") and is_running: |
|
|
elif Input.is_action_just_pressed("run") and is_running: |
|
|