📜  unity 刚体拖动和最高速度关系: - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:23.639000             🧑  作者: Mango

代码示例1
// If you want a rigidbody with non-zero drag to achieve a particular top speed (velocity.magnitude, always positive), use one of this equations:
rb.drag = sumOfAppliedAccelerations.magnitude / (topSpeed + sumOfAppliedAccelerations.magnitude * Time.fixedDeltaTime);
rb.drag = sumOfAppliedForces.magnitude / (rb.mass * topSpeed + sumOfAppliedForces.magnitude * Time.fixedDeltaTime);
// Conversely, top speed of a rigidbody with non-zero drag can be calculated from this equations:
topSpeed = sumOfAppliedAccelerations.magnitude * (1f / rb.drag - Time.fixedDeltaTime);
topSpeed = sumOfAppliedForces.magnitude / rb.mass * (1f / rb.drag - Time.fixedDeltaTime);