unity c# rigidbody freeze position code example
Example 1: rigidbody2d freeze position
public Rigidbody2D rb;
void Start()
{
rb.constraints = RigidbodyConstraints2D.FreezeAll;
}
Example 2: freeze position unity c#
rigidbody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ;