fix: aim at -buffertime where nt sync starts

This commit is contained in:
mischa 2024-04-26 23:37:31 +08:00
parent 6242873774
commit 4c5a63db8c

View File

@ -510,6 +510,12 @@ bool GuessForecastingStartPosition(out Vector3 position, out Quaternion rotation
// extrapolate this from latest time to blendingEndTime
// TODO validate rotation formula?
float timeToBlendingEnd = (float)(blendingEndTime - clientTimeline);
// right now, we aim exactly at the latest received state @ blendingEndTime.
// transform sync is always 'bufferTime' behind though.
// so aim for -buffertime behind to be perfectly smooth.
timeToBlendingEnd -= (float)bufferTime;
position = latest.position + velocity * timeToBlendingEnd;
rotation = latest.rotation * Quaternion.Slerp(Quaternion.identity, rotationDelta, timeToBlendingEnd / timeDelta);