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