- Home /
Disabling Rigidbody constraints on GameObject that script is attached to
Hello, 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;
and:
//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! Daniel
I've formatted your question for you. Remember to add an extra line between text and code.
Answer by iwaldrop · Jul 03, 2013 at 09:06 PM
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
}
Yes! It was the ".none;" I messed up its supposed to be ".None;" thank you!
Answer by Oribow · Jul 03, 2013 at 09:54 PM
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 ;)
Yes! This is simpler thank you :D I think i wil use this now :P
Answer by TechnoRazor · Nov 18, 2016 at 01:12 AM
Instead of doing gameObject.rigidbody
you should use gameObject.GetComponent<Rigidbody>()
because "rigidbody" is obsolete now in Unity 5.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Setting Scroll View Width GUILayout 1 Answer
How to drag a GameObject with touch but at a limited speed 1 Answer
Unity3D Ai wont shoot 1 Answer