WIP checkpoint: Client-side position sync + prediction/reconciliation
This commit is contained in:
@@ -196,6 +196,7 @@ func _handle_snapshot(snapshot_data: Dictionary) -> void:
|
||||
# RPC payloads can arrive as String or int depending on the transport
|
||||
# encoding, so check both rather than assuming.
|
||||
var my_state: Variant = players.get(my_id, players.get(str(my_id), null))
|
||||
print("DEBUG _handle_snapshot my_id=", my_id, " my_state=", my_state, " buffer_size=", _prediction_buffer.size(), " net.position=", position)
|
||||
if my_state == null or not (my_state is Dictionary):
|
||||
return
|
||||
|
||||
|
||||
@@ -73,6 +73,11 @@ func _run() -> void:
|
||||
var reconcile_handler := func(err): reconciled_this_round = true; correction_seen = err
|
||||
net.reconciled.connect(reconcile_handler)
|
||||
for i in 60:
|
||||
# Keep predicting (with no movement input) so the prediction buffer's
|
||||
# latest entry actually reflects the desynced position -- without
|
||||
# this, the buffer either empties out or keeps stale pre-desync
|
||||
# entries, and _handle_snapshot has nothing real to compare against.
|
||||
net.predict_and_send(1.0 / 30.0, 0.0, 0.0, false)
|
||||
await process_frame
|
||||
if reconciled_this_round:
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user