- Home /
Question by
DeathbyDomination · Aug 12, 2017 at 12:34 AM ·
script.parentdisable
how to disable a script when object has a child
I need help disabling the script of the parent when a child is Instantiated?
Comment
Best Answer
Answer by unidad2pete · Aug 12, 2017 at 03:41 AM
void Start()
{
if (transform.parent != null)
{
transform.parent.GetComponent<SCRIPTNAME>().enabled = false;
}
}
To destroy it:
void Start()
{
if (transform.parent != null)
{
Destroy(transform.parent.GetComponent<SCRIPTNAME>());
}
}
Your answer
Follow this Question
Related Questions
Vehicle Enter/Exit System for First/3rd Person :) 6 Answers
Instantiate object as child of scripted objects parent 1 Answer
Make a simple tree 1 Answer
Disabling child objects with their own child objects 1 Answer
Disable JS from C# 1 Answer