mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
FAST!
This commit is contained in:
parent
d656239476
commit
84ec18f61d
@ -209,11 +209,17 @@ protected virtual bool IsMoving() =>
|
|||||||
predictedRigidbody.velocity.sqrMagnitude >= velocitySensitivitySqr ||
|
predictedRigidbody.velocity.sqrMagnitude >= velocitySensitivitySqr ||
|
||||||
predictedRigidbody.angularVelocity.sqrMagnitude >= angularVelocitySensitivitySqr;
|
predictedRigidbody.angularVelocity.sqrMagnitude >= angularVelocitySensitivitySqr;
|
||||||
|
|
||||||
// when using Fast mode, we don't create any ghosts.
|
void Update()
|
||||||
// but we still want to check IsMoving() in order to support the same
|
|
||||||
// user callbacks.
|
|
||||||
void UpdateClient()
|
|
||||||
{
|
{
|
||||||
|
if (isServer) UpdateServer();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prediction always has a Rigidbody.
|
||||||
|
// position changes should always happen in FixedUpdate, even while kinematic.
|
||||||
|
// improves benchmark performance from 600 -> 870 FPS.
|
||||||
|
void FixedUpdateClient()
|
||||||
|
{
|
||||||
|
// PREDICTING checks state, which happens in update()
|
||||||
if (state == ForecastState.PREDICTING)
|
if (state == ForecastState.PREDICTING)
|
||||||
{
|
{
|
||||||
// we want to predict until the first server state came in.
|
// we want to predict until the first server state came in.
|
||||||
@ -230,32 +236,6 @@ void UpdateClient()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (state == ForecastState.BLENDING)
|
else if (state == ForecastState.BLENDING)
|
||||||
{
|
|
||||||
// BLENDING sets Rigidbody which happens in FixedUpdate()!
|
|
||||||
}
|
|
||||||
else if (state == ForecastState.FOLLOWING)
|
|
||||||
{
|
|
||||||
// hard set position & rotation.
|
|
||||||
// TODO snapshot interpolation
|
|
||||||
tf.SetPositionAndRotation(lastReceivedState.position, lastReceivedState.rotation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Update()
|
|
||||||
{
|
|
||||||
if (isServer) UpdateServer();
|
|
||||||
if (isClientOnly) UpdateClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
void FixedUpdateClient()
|
|
||||||
{
|
|
||||||
// physics movements need to be done in FixedUpdate.
|
|
||||||
|
|
||||||
// PREDICTING checks state, which happens in update()
|
|
||||||
// if (state == ForecastState.PREDICTING)
|
|
||||||
// {
|
|
||||||
// }
|
|
||||||
if (state == ForecastState.BLENDING)
|
|
||||||
{
|
{
|
||||||
// TODO snapshot interpolation
|
// TODO snapshot interpolation
|
||||||
|
|
||||||
@ -315,9 +295,12 @@ void FixedUpdateClient()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// FOLLOWING sets Transform, which happens in Update().
|
// FOLLOWING sets Transform, which happens in Update().
|
||||||
// else if (state == ForecastState.FOLLOWING)
|
else if (state == ForecastState.FOLLOWING)
|
||||||
// {
|
{
|
||||||
// }
|
// hard set position & rotation.
|
||||||
|
// TODO snapshot interpolation
|
||||||
|
tf.SetPositionAndRotation(lastReceivedState.position, lastReceivedState.rotation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FixedUpdate()
|
void FixedUpdate()
|
||||||
|
@ -22,4 +22,4 @@ Predicted:
|
|||||||
2024-03-15: 625 FPS Client, 1700 FPS Server // Vector3.MoveTowardsCustom()
|
2024-03-15: 625 FPS Client, 1700 FPS Server // Vector3.MoveTowardsCustom()
|
||||||
2024-03-18: 628 FPS Client, 1700 FPS Server // removed O(N) insertion from CorrectHistory()
|
2024-03-18: 628 FPS Client, 1700 FPS Server // removed O(N) insertion from CorrectHistory()
|
||||||
2024-03-28: 800 FPS Client, 1700 FPS Server // FAST mode prediction
|
2024-03-28: 800 FPS Client, 1700 FPS Server // FAST mode prediction
|
||||||
2024-04-04: 580 FPS Client, 1700 FPS Server // Forecasting & hand-off
|
2024-04-04: 870 FPS Client, 1700 FPS Server // Forecasting & hand-off
|
||||||
|
Loading…
Reference in New Issue
Block a user