feat: implement dash and wall run movement states for the player controller

This commit is contained in:
DottsGit
2026-06-04 11:47:08 -04:00
parent 5c2d648801
commit d8cb91e593
2 changed files with 23 additions and 4 deletions
+14 -4
View File
@@ -8,6 +8,7 @@ var params: MovementParams:
var elapsed: float = 0.0
var direction: Vector3 = Vector3.ZERO
var _exit_speed: float = 0.0
var _last_vel: Vector3 = Vector3.ZERO
# Cooldown tracked across dash instances
static var _last_dash_time: float = -999.0
@@ -51,6 +52,7 @@ func enter(_data: Dictionary = {}) -> void:
machine.player.velocity = direction * _exit_speed
machine.on_ground = false
_last_vel = machine.player.velocity
func exit() -> void:
@@ -70,9 +72,17 @@ func update(delta: float) -> void:
return
# Maintain dash velocity
var vel = direction * _exit_speed
if machine.player.is_on_floor():
var player := machine.player
var vel: Vector3 = player.velocity
if vel.distance_squared_to(_last_vel) > 100.0:
machine.switch_to("air")
return
vel = direction * _exit_speed
if player.is_on_floor():
vel.y = -0.5 # Snap to floor to handle ramps
machine.player.velocity = vel
machine.player.move_and_slide()
player.velocity = vel
player.move_and_slide()
_last_vel = player.velocity