PredictedRigidbody: add OnBeforeApplyState callback

This commit is contained in:
mischa 2024-02-06 18:06:26 +01:00
parent 157bf67a86
commit 3354363eae

View File

@ -431,6 +431,7 @@ void RecordState()
// optional user callbacks, in case people need to know about events.
protected virtual void OnSnappedIntoPlace() {}
protected virtual void OnBeforeApplyState() {}
protected virtual void OnCorrected() {}
void ApplyState(double timestamp, Vector3 position, Quaternion rotation, Vector3 velocity)
@ -468,6 +469,11 @@ void ApplyState(double timestamp, Vector3 position, Quaternion rotation, Vector3
return;
}
// we have a callback for snapping into place (above).
// we also need one for corrections without snapping into place.
// call it before applying pos/rot/vel in case we need to set kinematic etc.
OnBeforeApplyState();
// Rigidbody .position teleports, while .MovePosition interpolates
// TODO is this a good idea? what about next capture while it's interpolating?
if (correctionMode == CorrectionMode.Move)