feat: implement player movement controller and movement state machine system

This commit is contained in:
DottsGit
2026-06-06 21:16:48 -04:00
parent 30dbf7a4cd
commit 1a989f3586
2 changed files with 18 additions and 7 deletions
+11 -3
View File
@@ -675,9 +675,8 @@ func _physics_process(_delta: float) -> void:
_client_grapple_just_pressed = false
# Update synced properties for the grapple
if sm.current_state == "grapple" or sm.is_grapple_shooting:
synced_grapple_point = sm.grapple_point
synced_is_grapple_shooting = sm.is_grapple_shooting
synced_grapple_point = sm.grapple_point
synced_is_grapple_shooting = sm.is_grapple_shooting
# Update grapple rope visuals (runs on all clients for smooth interpolation)
if (synced_movement_state == "grapple" or synced_is_grapple_shooting) and camera:
@@ -985,12 +984,16 @@ func _input(event: InputEvent) -> void:
_on_respawn_pressed()
func _on_respawn_pressed() -> void:
if death_screen:
death_screen.visible = false
if multiplayer.is_server():
var spawn_pos = Vector3(randf_range(-5, 5), 5, randf_range(-5, 5))
rpc_respawn.rpc(spawn_pos)
else:
rpc_request_respawn.rpc_id(1)
var _last_respawn_request_time: float = 0.0
@rpc("any_peer", "call_local", "reliable")
func rpc_request_respawn() -> void:
if not multiplayer.is_server():
@@ -999,6 +1002,11 @@ func rpc_request_respawn() -> void:
if sender_id != 1 and sender_id != str(name).to_int():
return
var now = Time.get_ticks_msec() / 1000.0
if now - _last_respawn_request_time < 0.5:
return
_last_respawn_request_time = now
if is_dead:
var spawn_pos = Vector3(randf_range(-5, 5), 5, randf_range(-5, 5))
rpc_respawn.rpc(spawn_pos)