I know there must be a simple solution to this, but I can’t seem to figure it out. I have an object attached to an NPC, and I want to access it so as to enable and disable it through the script on the parent. How do I go about this?
I know there must be a simple solution to this, but I can’t seem to figure it out. I have an object attached to an NPC, and I want to access it so as to enable and disable it through the script on the parent. How do I go about this?
Try this
Transform aChild = transform.FindChild( "child name" );
if( aChild != null )
{
Debug.Log( "Found child" );
aChild.gameobject.SetActive( true ); // false
}
else Debug.Log( "Child not found" );
Attach it to the parent