mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
Prediction: only set velocity if not kinematic
This commit is contained in:
parent
54c8caac54
commit
e7c8898679
@ -495,8 +495,12 @@ void ApplyState(double timestamp, Vector3 position, Quaternion rotation, Vector3
|
||||
// to stop and start moving again on client - slide as well here.
|
||||
predictedRigidbody.position = position;
|
||||
predictedRigidbody.rotation = rotation;
|
||||
predictedRigidbody.velocity = velocity;
|
||||
predictedRigidbody.angularVelocity = angularVelocity;
|
||||
// projects may keep Rigidbodies as kinematic sometimes. in that case, setting velocity would log an error
|
||||
if (!predictedRigidbody.isKinematic)
|
||||
{
|
||||
predictedRigidbody.velocity = velocity;
|
||||
predictedRigidbody.angularVelocity = angularVelocity;
|
||||
}
|
||||
|
||||
// clear history and insert the exact state we just applied.
|
||||
// this makes future corrections more accurate.
|
||||
@ -536,9 +540,13 @@ void ApplyState(double timestamp, Vector3 position, Quaternion rotation, Vector3
|
||||
predictedRigidbody.rotation = rotation;
|
||||
}
|
||||
|
||||
// there's only one way to set velocity
|
||||
predictedRigidbody.velocity = velocity;
|
||||
predictedRigidbody.angularVelocity = angularVelocity;
|
||||
// there's only one way to set velocity.
|
||||
// (projects may keep Rigidbodies as kinematic sometimes. in that case, setting velocity would log an error)
|
||||
if (!predictedRigidbody.isKinematic)
|
||||
{
|
||||
predictedRigidbody.velocity = velocity;
|
||||
predictedRigidbody.angularVelocity = angularVelocity;
|
||||
}
|
||||
}
|
||||
|
||||
// process a received server state.
|
||||
|
@ -23,7 +23,6 @@ public static void MoveRigidbody(GameObject source, GameObject destination)
|
||||
rigidbodyCopy.mass = original.mass;
|
||||
rigidbodyCopy.drag = original.drag;
|
||||
rigidbodyCopy.angularDrag = original.angularDrag;
|
||||
rigidbodyCopy.angularVelocity = original.angularVelocity;
|
||||
rigidbodyCopy.useGravity = original.useGravity;
|
||||
rigidbodyCopy.isKinematic = original.isKinematic;
|
||||
rigidbodyCopy.interpolation = original.interpolation;
|
||||
@ -33,7 +32,13 @@ public static void MoveRigidbody(GameObject source, GameObject destination)
|
||||
rigidbodyCopy.freezeRotation = original.freezeRotation;
|
||||
rigidbodyCopy.position = original.position;
|
||||
rigidbodyCopy.rotation = original.rotation;
|
||||
rigidbodyCopy.velocity = original.velocity;
|
||||
|
||||
// projects may keep Rigidbodies as kinematic sometimes. in that case, setting velocity would log an error
|
||||
if (!original.isKinematic)
|
||||
{
|
||||
rigidbodyCopy.velocity = original.velocity;
|
||||
rigidbodyCopy.angularVelocity = original.angularVelocity;
|
||||
}
|
||||
|
||||
// destroy original
|
||||
GameObject.Destroy(original);
|
||||
|
Loading…
Reference in New Issue
Block a user