rigidbody constraints no longer part of unityscript or something?

Hey, Im using javascript or unityscript (whatever) and heres my code which, according to the documentation should stop movement of the rigidbody on the Z axis;

rigidbody.constraints = RigidbodyConstraints.FreezePositionZ;

Now, when I put this into my script to didn't work, at all, those names (constraints, etc...) are recognised by the editor or something, have the names changed or something?

Im using unity 3.0.0f5 pro...

I’m also not able to get this bit of code to work and can’t seem to find any answers online. When I run the script, I get a NullReferenceException, and even though I added a conditional testing for a NRE:

if(rigidbody != null){
		rigidbody.constraints = RigidbodyConstraints.FreezeNone;
	} else {
		Debug.Log("rigidbody is null for some mysterious reason");

I don’t get my Debug message at all–just the same NRE.

Any help would be greatly appreciated. Thanks.

To clear things up a bit RigidbodyConstraints is an enumeration while constraints derived from Rigidbody is a variable. The constraints variable can take several layered values from the enumeration RigidbodyConstraints.

Doing this should freeze all motion on the Z-axis:

rigidbody.constraints = RigidbodyConstraints.FreezePositionZ;

To check if an object has a component named rigidbody use:

if (rigidbody)

If the script isn’t on the object use:

if (theReference.rigidbody)

which for instance on a trigger could be:

function OnTriggerEnter (other : Collider) {
    if (other.rigidbody)