- Home /
How Do You Parent an Object With Scripts?
I would like to make an object parented to a specific bone (with script). How would I do this? Also, how do I make something (in)visible with script?
Answer by SisterKy · Jul 15, 2011 at 04:08 AM
invisible: YourGameObject.renderer.enabled = false;
parenting: TheChildObject.parent = TheBoneObject;
Greetz, Ky.
When I use the code and put it in a box called test, it says "Assets/Scripts/Pickup.js(5,17): BCE0005: $$anonymous$$ identifier: 'Test'." Here's the code: function OnCollisionEnter(collision : Collision) { if(collision.gameObject.tag == "Character") { Test.renderer.enabled = false; }
}
you need var Test; at the beginning of your script and assign whatever you want to make invisible in the editor. (however, it would be better to call it 'test', not 'Test'. Upper case is for Functions, lower case for variables) Greetz, $$anonymous$$y.
How do you assign an object to a variable? I have a cube called test.
Come on, dude... Do some reading on your own. It's not that hard to find out. Do the tutorials http://unity3d.com/support/resources/tutorials/ ; try this: http://www.google.com/cse/home?cx=002470491425767499270:iugs1ezlsfq People will get annoyed if you ask questions that are so easy to figure out on your own... you will look lazy and stupid. Greetz, $$anonymous$$y.
Your answer
Follow this Question
Related Questions
Can a parent SetActive a child GameObject anymore 2 Answers
Make a simple tree 1 Answer
Parent mesh problem 0 Answers
error CS0029: Cannot implicitly convert type `UnityEngine.ParticleSystem.MinMaxCurve' to `float' 0 Answers
How can i check and fire an event when the user look at specific object ? 0 Answers