mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
set rigidbody in fixedupdate
This commit is contained in:
parent
4a8ad22412
commit
6330adf092
@ -226,6 +226,32 @@ void UpdateClient()
|
||||
}
|
||||
}
|
||||
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.
|
||||
|
||||
if (state == ForecastState.PREDICTING)
|
||||
{
|
||||
// PREDICTING checks state, which happens in update()
|
||||
}
|
||||
else if (state == ForecastState.BLENDING)
|
||||
{
|
||||
// TODO snapshot interpolation
|
||||
|
||||
@ -319,24 +345,13 @@ void UpdateClient()
|
||||
}
|
||||
else if (state == ForecastState.FOLLOWING)
|
||||
{
|
||||
// hard set position & rotation.
|
||||
// TODO snapshot interpolation
|
||||
tf.SetPositionAndRotation(lastReceivedState.position, lastReceivedState.rotation);
|
||||
// FOLLOWING sets Transform, which happens in Update().
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (isServer) UpdateServer();
|
||||
if (isClientOnly) UpdateClient();
|
||||
}
|
||||
|
||||
void FixedUpdate()
|
||||
{
|
||||
// on clients (not host) we record the current state every FixedUpdate.
|
||||
// this is cheap, and allows us to keep a dense history.
|
||||
if (!isClientOnly) return;
|
||||
|
||||
if (isClientOnly) FixedUpdateClient();
|
||||
}
|
||||
|
||||
void OnDrawGizmos()
|
||||
|
Loading…
Reference in New Issue
Block a user