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