Sync player piloting state

This commit is contained in:
Chris Bell 2024-12-19 20:38:54 -06:00
parent fa7c562bb5
commit 13a1845e6b

View File

@ -143,13 +143,15 @@ func _on_property_update(uuid: String, property_name: String, value: Variant):
_handle_ship_sync_rotation(value) _handle_ship_sync_rotation(value)
else: else:
node.set(property_name, value) node.set(property_name, value)
else: else:
printerr("Received property update but node_id is wrong? Expected " + str(uuid) + " but got " + str(uuid)) printerr("Received property update but node_id is wrong? Expected " + str(uuid) + " but got " + str(uuid))
func _sync_piloting_state(): func _sync_piloting_state():
NetworkManager.sync_property(network_uuid, "ship_is_piloted", ship_is_piloted) NetworkManager.sync_property(network_uuid, "ship_is_piloted", ship_is_piloted)
NetworkManager.sync_property(network_uuid, "piloting_player", piloting_player) if piloting_player != null:
NetworkManager.sync_property(network_uuid, "piloting_player", piloting_player.network_uuid)
else:
NetworkManager.sync_property(network_uuid, "piloting_player", "")
func _send_ship_sync(): func _send_ship_sync():
if Time.get_ticks_msec() - last_sync_time > sync_interval * 1000: if Time.get_ticks_msec() - last_sync_time > sync_interval * 1000:
@ -176,4 +178,4 @@ func _handle_ship_sync_rotation(rot: Vector3):
angular_velocity = delta_rot.get_euler() / delta_time angular_velocity = delta_rot.get_euler() / delta_time
# Apply server rotation directly # Apply server rotation directly
global_rotation = Quaternion.from_euler(rot).get_euler() global_rotation = Quaternion.from_euler(rot).get_euler()