Disabling Rigidbody constraints on GameObject that script is attached to

I know this is an easy fix. I must be missing something, i want to disable all bridge body constraints on the object that the script as attached to. For some reason i cant seem to access “this” gameobject.

I have tried:

	//Cause the menu to FALL to the Ground
	this.gameObject.GetComponent.rigidbody.constraints = RigidbodyConstraints.none;

I have also tried:

	//Cause the menu to FALL to the Ground
	this.gameObject.rigidbody.constraints = RigidbodyConstraints.none;


	//Cause the menu to FALL to the Ground
	this.rigidbody.constraints = RigidbodyConstraints.none;

Any Help will be appreciated! I will take the time to mark it correct too if your answer is of help. Thanks!

Assuming this is on a MonoBehaviour, you just do:

rigidbody.constraints = RigidbodyConstraints.None;

You don’t need the ‘this’ keyword unless you’re inside a method with a parameter of the same name, ex:

void SomeMethod(Transform transform)
    // this.transform = this transform
    // transform = the transform passed as a parameter

I think you can make your Menu falling much easyer, when you work with the gravity of the Rigidbody.
Make your gravity disable and write this in your Code to make them activatet.

gameObject.rigidbody.gravity.enable = true;

Sorry for my bad English :wink:

Instead of doing gameObject.rigidbody you should use gameObject.GetComponent<Rigidbody>() because “rigidbody” is obsolete now in Unity 5.