Ship mostly works #10

Merged
chrisbell merged 60 commits from feature/ship-syncing into develop 2024-12-29 04:35:51 +00:00
Showing only changes of commit 359e4554ba - Show all commits

View File

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