Added running state
This commit is contained in:
parent
dbfdc6f422
commit
317af8672a
23
modules/actors/player/scripts/states/running.gd
Normal file
23
modules/actors/player/scripts/states/running.gd
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
extends LocomotionState
|
||||||
|
|
||||||
|
@onready var player: Node3D = $"../.."
|
||||||
|
|
||||||
|
func physics_update(delta: float) -> void:
|
||||||
|
player.process_input()
|
||||||
|
|
||||||
|
if not player.locomotion.is_on_floor():
|
||||||
|
transition.emit("Airborne")
|
||||||
|
|
||||||
|
if player.wish_jump:
|
||||||
|
player.locomotion.velocity.y = player.locomotion.get_current_settings().JUMP_IMPULSE
|
||||||
|
else:
|
||||||
|
player.locomotion.velocity = player.locomotion.update_velocity(delta)
|
||||||
|
|
||||||
|
player.locomotion.move_and_slide()
|
||||||
|
player.locomotion.update_collider_height(delta)
|
||||||
|
|
||||||
|
if Input.is_action_pressed("walk"):
|
||||||
|
transition.emit("Walking")
|
||||||
|
|
||||||
|
if Input.is_action_pressed("duck") or player.locomotion.has_collision_above($".".settings.HEIGHT):
|
||||||
|
transition.emit("Ducking")
|
Loading…
x
Reference in New Issue
Block a user