it didnt work
This commit is contained in:
parent
b50bdb52ec
commit
501085bf57
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user