freeze position unity 2d 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;