From 283d313f886c2ca0efaef032d3b2bbf185c7e9ab Mon Sep 17 00:00:00 2001 From: Chris Bell Date: Sat, 28 Dec 2024 21:17:55 -0600 Subject: [PATCH] maybe maybe maybe --- assets/core/ships/ship_script.gd | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/assets/core/ships/ship_script.gd b/assets/core/ships/ship_script.gd index 60eda7d..479ec6e 100644 --- a/assets/core/ships/ship_script.gd +++ b/assets/core/ships/ship_script.gd @@ -118,26 +118,30 @@ func _on_player_exited(body): body.call_deferred("reparent", get_node("/root/DevLevel/"), true) body.ship_exited() print("Player exited the ship area.") - - + + func send_network_update(): if NetworkManager.is_host: if ship_is_piloted and piloting_player.steam_id == NetworkManager.steam_id or !ship_is_piloted: - NetworkManager.sync_property_to_all_except_host(network_uuid, "global_position", global_position) - NetworkManager.sync_property_to_all_except_host(network_uuid, "global_rotation", global_rotation) + if global_position != previous_position or global_transform.basis.get_rotation_quaternion() != previous_rotation: + NetworkManager.sync_property_to_all_except_host(network_uuid, "global_position", global_position) + NetworkManager.sync_property_to_all_except_host(network_uuid, "global_rotation", global_transform.basis.get_rotation_quaternion()) + previous_position = global_position + previous_rotation = global_transform.basis.get_rotation_quaternion() elif ship_is_piloted and piloting_player.steam_id == NetworkManager.steam_id: - NetworkManager.sync_property_to_all(network_uuid, "global_position", global_position) - NetworkManager.sync_property_to_all(network_uuid, "global_rotation", global_rotation) - else: - GameConsole.log_warning("This should never be hit. If it is, something is wrong with send network logic on the ship.") + if global_position != previous_position or global_transform.basis.get_rotation_quaternion() != previous_rotation: + NetworkManager.sync_property_to_all(network_uuid, "global_position", global_position) + NetworkManager.sync_property_to_all(network_uuid, "global_rotation", global_transform.basis.get_rotation_quaternion()) + previous_position = global_position + previous_rotation = global_transform.basis.get_rotation_quaternion() func receive_global_position_update(value: Vector3): target_position = value -func receive_global_rotation_update(value: Quaternion): - target_rotation = value +func receive_global_rotation_update(value: Vector3): + target_rotation = Quaternion().from_euler(value) func _on_property_update(node_id: String, property_name: String, value: Variant) -> void: