refactor to state machine

This commit is contained in:
2025-02-02 01:08:44 +09:00
parent c8c5c08b4d
commit be682b2813
18 changed files with 379 additions and 121 deletions
+16
View File
@@ -0,0 +1,16 @@
extends MultiplayerSynchronizer
@export var direction: Vector2 = Vector2.ZERO
@export var walking: bool = false
func _ready() -> void:
if multiplayer.is_server() or get_multiplayer_authority() != multiplayer.get_unique_id():
set_process(false)
set_physics_process(false)
return
func _physics_process(_delta: float) -> void:
var directional_input := Input.get_vector("move_right", "move_left", "move_forward", "move_back")
var camera_adjusted: Vector3 = (directional_input.x * %CameraTarget.global_basis.z) + (directional_input.y * %CameraTarget.global_basis.x)
direction = Vector2(camera_adjusted.x, camera_adjusted.z).rotated(PI / 2.0).normalized()
walking = Input.is_action_pressed("walk")