- Home /
How to disable component of the child object
I have game object Armor, which contain child object Smoke Trail and that contain component Ellipsoid Particle Emitter. And on Armor I have a script, from which I want to disable Ellipsoid Particle Emitter, but my code doesn't works.
armor.GetComponentInChildren ("SmokeTrail").gameObject.SetActive(false);
Answer by OrbitGames · Aug 31, 2014 at 02:09 PM
You are using GetComponentInChildren Wrong...
You have to insert the component name not the GOs name
The Code would be:
GetComponentInChildren<EllipsoidParticleEmitter>().enabled = false;
If you want to disable the whole GO you should use transform.Find
transform.Find("Smoke Trail").gameObject.SetActive(false);
both scripts are untested
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Disabling A Script on a GameObject From a Different Script 2 Answers
GetComponentsInChildren Network Reliable 0 Answers
Help removing an AudioSource component from another script 0 Answers