here are the commands i use:
GetComponent ().constraints = RigidbodyConstraints2D.FreezeRotation;
GetComponent ().constraints = RigidbodyConstraints2D.FreezepositionX;
It only gives me the choise to freeze position x and y or the rotation only or alla of them at the same time.
I just only want to have the position.y unchecked which i can do it manually in the inspector but not in the script.
Any ideas???
MelvMay
2
The constraints property is a Bitmask. Simply setting it to a single option only sets that option. You need to use the | (bitwise OR) operator to merge them together before setting it i.e.
constraints = RigidbodyConstraints2D.FreezeRotation | RigidbodyConstraints2D.FreezepositionX;