From d82445114dfde1329efef8cfe63090a73474f2e9 Mon Sep 17 00:00:00 2001 From: Chris Bell Date: Thu, 19 Dec 2024 09:04:45 -0600 Subject: [PATCH] Potential ship fix --- assets/core/ships/ship_script.gd | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/assets/core/ships/ship_script.gd b/assets/core/ships/ship_script.gd index de055eb..9c83702 100644 --- a/assets/core/ships/ship_script.gd +++ b/assets/core/ships/ship_script.gd @@ -70,10 +70,12 @@ func _physics_process(_delta): linear_velocity = linear_velocity.normalized() * top_speed angular_velocity.y = clamp(angular_velocity.y, -max_turn_speed, max_turn_speed) - + + # Self level slowly if host global_rotation.x = lerpf(global_rotation.x, 0, 0.1) global_rotation.z = lerpf(global_rotation.z, 0, 0.1) - + + # Sync position and rotation for all players except the piloting player if piloting_player == null or !piloting_player.is_network_authority: if old_global_position_cache != global_position: NetworkManager.sync_property(uuid, "global_position", global_position) @@ -110,7 +112,13 @@ func _add_ship_helm(_ship_helm_scene: PackedScene): func _on_property_update(uuid: String, property_name: String, value: Variant): if NetworkManager.node_map.has(uuid): var node = NetworkManager.node_map[uuid] - node.set(property_name, value) + if node != self: + node.set(property_name, value) + else: + if property_name == "global_position" and (global_position - value).length() > 0.01: + global_position = value + elif property_name == "global_rotation" and (global_rotation - value).length() > 0.01: + global_rotation = value else: printerr("Received property update but node_id is wrong? Expected " + str(uuid) + " but got " + str(uuid))