feat(movement): add movement state machine with air/ground/wallrun/slide/dash/ground states

- MovementStateMachine: core state machine base
- MovementParams: export-rich tunable resource
- StateGround/StateAir: grounded & aeriel locomotion with coyote, buffered jump, bunny hop
- StateWallRun / StateWallCling: wall-based traversal with wall-jump off
- StateSlide: sprint-parallel slide with friction fallout
- StateDash: burst dash with momentum brake
- PlayerMovementController: entry point wiring to CharacterBody3D
- input_map.cfg: full action map reference file
- characters/player/player_base.tscn: placeholder scene
- movement/tests/test_fsm_runner.gd: 9-state unit test runner

Closes #1
This commit is contained in:
2026-06-02 22:36:00 -04:00
parent a4863a7b08
commit 202f67fa32
14 changed files with 993 additions and 6 deletions
+60
View File
@@ -0,0 +1,60 @@
extends Node
class_name StateSlide
var machine: MovementStateMachine
var params: MovementParams:
get: return machine.params
var elapsed: float = 0.0
func enter(_data: Dictionary = {}) -> void:
elapsed = 0.0
machine.register_chain_mechanic("slide")
# Lower player capsule
var player_node = machine.player
var shape: CapsuleShape3D = player_node.shape_owner_get_shape(0)
if shape:
shape.height = shape.height * 0.5
func exit() -> void:
pass
func update(delta: float) -> void:
elapsed += delta
var vel: Vector3 = machine.player.velocity
var forward: Vector3 = -machine.player.global_transform.basis.z
if forward.length_squared() > 1.0:
forward = forward.normalized()
vel.x = forward.x * params.slide_speed * machine.get_effective_speed(1.0)
vel.z = forward.z * params.slide_speed * machine.get_effective_speed(1.0)
vel.x *= pow(params.slide_friction, delta)
vel.z *= pow(params.slide_friction, delta)
machine.player.velocity = vel
machine.player.move_and_slide()
if machine.player.is_on_floor():
machine.on_ground = true
var speed := Vector3(vel.x, 0.0, vel.z).length()
if speed < params.slide_min_speed or elapsed > params.slide_duration:
var shape: CapsuleShape3D = machine.player.shape_owner_get_shape(0)
if shape:
shape.height = shape.height * 2.0
machine.register_chain_mechanic("slide_end")
machine.switch_to("ground")
return
else:
var shape2: CapsuleShape3D = machine.player.shape_owner_get_shape(0)
if shape2:
shape2.height = shape2.height * 2.0
machine.on_ground = false
machine.switch_to("air")
if not machine.input_crouch or not machine.input_sprint:
var shape3: CapsuleShape3D = machine.player.shape_owner_get_shape(0)
if shape3:
shape3.height = shape3.height * 2.0
machine.register_chain_mechanic("slide_cancel")
machine.switch_to("ground")