unity 2d rigidbody2d freeze code example
Example 1: rigidbody2d freeze position
public Rigidbody2D rb;
void Start()
{
rb.constraints = RigidbodyConstraints2D.FreezeAll;
}
Example 2: how to freeze x and y position in rb2d with code unity
rb.constraints = RigidbodyConstraints2D.FreezePositionX;
rb.constraints = RigidbodyConstraints2D.FreezePositionY;
Example 3: unity rigidbody2d disable
//you can't :(
//you can delete it with
Destroy(RigidBody2D);