+extends Move
+class_name Walk
+
+
+func should_enter(input) -> String:
+ input.actions.sort_custom(moves_priority_sort)
+ return input.actions[0]
+
+
+func update(input: InputPacket, delta: float):
+ # Get the XZ input direction based on player's input relative to the camera
+ var forward := camera.global_basis.z
+ var right := camera.global_basis.x
+ var move_direction := (
+ forward * input.movement_direction.y + right * input.movement_direction.x
+ ).normalized()
+ move_direction.y = 0
+
+ # if we're not stuck, then it's okay to set the velocity
+ var floor_normal = player.get_floor_normal()
+ var ground_slope_input = (PI / 2) - player.velocity.angle_to(floor_normal)
+ player.velocity = player.velocity.move_toward(
+ move_direction * (player.walk_speed + ground_slope_input * player.walk_speed),
+ player.acceleration * delta
+ )
+
+ player.move_and_slide()