Unity 2D Обмеження швидкості

2075 / Unity / 2D / Додатково / Обмеження швидкості

 

if (rigidbody.velocity.sqrMagnitude > maxVelocity)
{
  //smoothness of the slowdown is controlled by the 0.99f,
  //0.5f is less smooth, 0.9999f is more smooth
  rigidbody.velocity *= 0.99f;
}