Activate child only problem

Hello, I have a problem.

Its a simple collectible I made.

I have made it that when you collide with the object, it should disappear and play a spark effect. The spark effect is the child of the collectible. So the code simply hides the object when it collides, activates the child which is a particle system to play the particle effect and then destroys itself after 0.5 seconds.

So far everything works but I don’t know how to activate the child as I don’t want to activate just one part of the child, I want the whole child object to be activated.

The script is for the character, when the character enters the object, it will check the tag and do what the code tells it to do.

void OnTriggerEnter(Collider other)

			//switch off renderer of current object to ensure that it cannot be seen
			other.gameObject.renderer.enabled = false; 

//Need code to activate the child of the "other" object 

			Destroy(gameObject,0.5f);//destroy object after allotted time


You can use Transform.Find() to get the child object of your “other” object and can set it to become active using GameObject.SetActive

So it would be like:


The above line of code will not and does not work and as stated by @Wolfram, the correct code is:




if it’s the first child, then

Destroy(gameObject, 0.5);

but you won’t see much particle effects in 0.5 seconds … :slight_smile: