Physics Extensions

Overview

EXTENSIONS

ClampVelocity

  • ClampVelocity(float min, float max)
  • ClampVelocity(Vector2 min, Vector2 max) - Rigidbody2D-Only
  • ClampVelocity(Vector3 min, Vector3 max) - Rigidbody-Only

Clamps the Rigidbody’s velocity. There are some variants for this method.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
using NutTools;
using UnityEngine;

public class MyClass: MonoBehaviour
{
    Rigidbody rbody;
    Rigidbody2D rbody2d;

    void MyMethod()
    {
        // ...
        rbody.ClampVelocity(-3f, 3f);
        rbody2d.ClampVelocity(new Vector2(-3f, -5f), new Vector2(3f, 5f));
        // ...
    }
}

GET HELP

Join this Discord server to get help from the community, suggest new features, and vote on future updates!

See also

  • Array and List Extensions
  • GameObject and Component Extensions
  • ParticleSystem Extensions
  • Texture Extensions
  • Value Extensions