- Home /
Using "Tag" to disable Rigidbody Constraints
Hello, I cant figure this out for the life of me. How do I correctly reference all the tagged objects and remove the reigidbody constraints from them?
//Cause the menu to FALL to the Ground
GameObject.FindGameObjectsWithTag ("MainMenu");
rigidbody.constraints = RigidbodyConstraints.None;
Thanks, Daniel
Just to be clear I am using JavaScript for anyone looking at this question in the future.
Answer by iwaldrop · Jul 04, 2013 at 12:13 AM
You have to store the reference that FindGameObjectsWithTag returns, then loop through them and do your thing.
GameObject[] gos = GameObject.FindGameObjectsWithTag ("MainMenu");
foreach (GameObject go in gos)
go.rigidbody.constraints = RigidbodyConstraints.None;
@iwaldrop Im getting two errors here, Since i have no experience with using tags yet could you explain how to fix it? Btw heres the code as well:
function On$$anonymous$$ouseDown () {
audio.clip = SelectSound;
audio.Play();
//$$anonymous$$ove to multiplayer$$anonymous$$enu First
//Cause the menu to FALL to the Ground
GameObject[] gos = GameObject.FindGameObjectsWithTag ("$$anonymous$$ain$$anonymous$$enu");
foreach (GameObject go in gos)
go.rigidbody.constraints = RigidbodyConstraints.None;
iTweenEvent.GetEvent(menuCam, "$$anonymous$$ain$$anonymous$$enuTo$$anonymous$$ultiplayerOptions").Play();
}
Thank you btw for your Quick Response!
You need to include the errors that you're getting with questions about error messages.
@iwaldrop hmm, I did for some reason the picture didnt go through here is another picture
Shoot. I hate when that happens. It's probably because your using JavaScript and I wrote that in C#. Try this, but I have no idea if it'll work or not because I'm not that familiar with Unity's javascript implementation.
var gos = GameObject.FindGameObjectsWithTag ("$$anonymous$$ain$$anonymous$$enu");
for (int i = 0; i < gos.Length; i++)
gos[i].rigidbody.constraints = RigidbodyConstraints.None;
Yes it is in JavaScript sorry i didn't define that :P, let me see here looks WAY more familiar to me :D giving it a try.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Integer in if statement, scripting help 1 Answer
Simple code is not recognizing tag anymore. 0 Answers
Attach object as child using code 1 Answer
Changing material Color using RBG? 3 Answers