From 501085bf57a07077ceb444892aa8c119d12584ab Mon Sep 17 00:00:00 2001 From: Chris Bell Date: Sat, 28 Dec 2024 16:19:01 -0600 Subject: [PATCH] it didnt work --- assets/core/ships/ship_script.gd | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/assets/core/ships/ship_script.gd b/assets/core/ships/ship_script.gd index b916b2a..d0248a8 100644 --- a/assets/core/ships/ship_script.gd +++ b/assets/core/ships/ship_script.gd @@ -179,19 +179,26 @@ func _send_ship_sync(): func _handle_ship_sync_position(pos: Vector3): if piloting_player and not piloting_player.is_network_authority: - # Correct prediction with server data only if the difference is significant - if (pos - global_position).length() > 0.1: + # Correct prediction with server data + var correction_threshold = 0.5 # Adjust based on your desired tolerance + if (pos - global_position).length() > correction_threshold: predicted_position = pos linear_velocity = (pos - global_position) / delta_time + # Send correction update to the client + var correction = {"position": pos} + NetworkManager.sync_property_to_peer(network_uuid, correction, piloting_player.network_uuid) func _handle_ship_sync_rotation(rot: Vector3): if piloting_player and not piloting_player.is_network_authority: - # Correct prediction with server data only if the difference is significant + var correction_threshold = 0.1 # Adjust based on your desired tolerance var received_rotation = Quaternion.from_euler(Vector3(rot.x, rot.y, rot.z)) var delta_rot = received_rotation * global_rotation.inverse() - if delta_rot.length() > 0.1: + if delta_rot.length() > correction_threshold: predicted_rotation = received_rotation angular_velocity = delta_rot.get_euler() / delta_time + # Send correction update to the client + var correction = {"rotation": rot} + NetworkManager.sync_property_to_peer(network_uuid, correction, piloting_player.network_uuid) # Apply server rotation directly global_rotation = Quaternion.from_euler(rot).get_euler()