More AI lol

This commit is contained in:
Chris Bell 2024-12-19 20:45:24 -06:00
parent 13a1845e6b
commit 359e4554ba

View File

@ -163,18 +163,18 @@ func _send_ship_sync():
func _handle_ship_sync_position(pos: Vector3): func _handle_ship_sync_position(pos: Vector3):
if piloting_player and not piloting_player.is_network_authority: if piloting_player and not piloting_player.is_network_authority:
# Correct prediction with server data # Correct prediction with server data only if the difference is significant
if (pos - global_position).length() > 0.1:
predicted_position = pos predicted_position = pos
linear_velocity = (pos - global_position) / delta_time linear_velocity = (pos - global_position) / delta_time
func _handle_ship_sync_rotation(rot: Vector3): func _handle_ship_sync_rotation(rot: Vector3):
if piloting_player and not piloting_player.is_network_authority: if piloting_player and not piloting_player.is_network_authority:
# Correct prediction with server data # Correct prediction with server data only if the difference is significant
predicted_rotation = Quaternion.from_euler(Vector3(rot.x, rot.y, rot.z))
# Calculate angular velocity based on rotation change
var received_rotation = Quaternion.from_euler(Vector3(rot.x, rot.y, rot.z)) var received_rotation = Quaternion.from_euler(Vector3(rot.x, rot.y, rot.z))
var delta_rot = received_rotation * global_rotation.inverse() var delta_rot = received_rotation * global_rotation.inverse()
if delta_rot.length() > 0.001: if delta_rot.length() > 0.1:
predicted_rotation = received_rotation
angular_velocity = delta_rot.get_euler() / delta_time angular_velocity = delta_rot.get_euler() / delta_time
# Apply server rotation directly # Apply server rotation directly