Predicted Billiards: remove unused code

This commit is contained in:
mischa 2024-04-02 17:12:48 +08:00
parent 779da04b7f
commit 83807e978d

View File

@ -63,7 +63,7 @@ public void OnDraggedBall(Vector3 force)
// apply on server as well. // apply on server as well.
// not necessary in host mode, otherwise we would apply it twice. // not necessary in host mode, otherwise we would apply it twice.
if (!isServer) CmdApplyForce(force, NetworkTime.predictedTime); if (!isServer) CmdApplyForce(force);
} }
// while prediction is applied on clients immediately, // while prediction is applied on clients immediately,
@ -76,7 +76,7 @@ public void OnDraggedBall(Vector3 force)
// TODO send over unreliable with ack, notify, etc. later // TODO send over unreliable with ack, notify, etc. later
[Command] [Command]
void CmdApplyForce(Vector3 force, double predictedTime) void CmdApplyForce(Vector3 force)
{ {
if (!IsValidMove(force)) if (!IsValidMove(force))
{ {
@ -84,30 +84,6 @@ void CmdApplyForce(Vector3 force, double predictedTime)
return; return;
} }
// client is on a predicted timeline.
// double check the prediction - it should arrive at server time.
//
// there are multiple reasons why this may be off:
// - time prediction may still be adjusting itself
// - time prediction may have an issue
// - server or client may be lagging or under heavy load temporarily
// - unreliable vs. reliable channel latencies are signifcantly different
// for example, if latency simulation is only applied to one channel!
double delta = NetworkTime.time - predictedTime;
if (delta < -0.010)
{
Debug.LogWarning($"Cmd predictedTime was {(delta*1000):F0}ms behind the server time. This could occasionally happen if the time prediction is off. If it happens consistently, check that unreliable NetworkTime and reliable [Command]s have the same latency. If they are off, this will cause heavy jitter.");
}
else if (delta > 0.010)
{
// TODO consider buffering inputs which are ahead, apply next frame
Debug.LogWarning($"Cmd predictedTime was {(delta*1000):F0}ms ahead of the server time. This could occasionally happen if the time prediction is off. If it happens consistently, check that unreliable NetworkTime and reliable [Command]s have the same latency. If they are off, this will cause heavy jitter. If reliable & unreliable latency are similar and this still happens a lot, consider buffering inputs for the next frame.");
}
else
{
Debug.Log($"Cmd predictedTime was {(delta*1000):F0}ms close to the server time.");
}
// apply force // apply force
ApplyForceToWhite(force); ApplyForceToWhite(force);
} }