Feat/10 adding multiplayer fundamentals #14

Merged
Dotts merged 16 commits from feat/10-adding-multiplayer-fundamentals into main 2026-06-06 19:31:25 -07:00
2 changed files with 18 additions and 7 deletions
Showing only changes of commit 1a989f3586 - Show all commits
+7 -4
View File
@@ -94,11 +94,14 @@ func _physics_process(delta: float) -> void:
_try_start_grapple()
if is_grapple_shooting:
grapple_shoot_time += delta
if grapple_shoot_time >= grapple_travel_time:
if not input_grapple:
is_grapple_shooting = false
movement_event.emit("grapple_latch", {})
switch_to("grapple")
else:
grapple_shoot_time += delta
if grapple_shoot_time >= grapple_travel_time:
is_grapple_shooting = false
movement_event.emit("grapple_latch", {})
switch_to("grapple")
# Manage global crouch state
var want_crouch = input_crouch
+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)