Particle Emitter not appearing on Enemy Death
Hello, I've been trying to get a particle emitter attached to my enemy, but no matter what I do it doesn't appear. There are no errors in the console and the actual clone of the particle prefab appears in the hierarchy, it just never appears. Here's the partial code:
public GameObject soulCollected;
void Start ()
{
myAnimator = GetComponent<Animator> ();
isDead = false;
camFollow = FindObjectOfType<CameraFollow> ();
AudioSource[] myAudio = GetComponents<AudioSource> ();
enemyCollected = myAudio [0];
enemyHit = myAudio [1];
}
void Update()
{
}
public void OnTriggerEnter2D (Collider2D other)
{
if (other.tag == "Sword")
{
isDead = true;
{
if (isDead)
{
myAnimator.SetTrigger ("isDead");
Instantiate (soulCollected, transform.position, transform.rotation);
gameObject.GetComponent<CircleCollider2D> ().enabled = false;
enemyCollected.Play ();
DestroyObject (gameObject, enemyCollected.clip.length);
}
Does it appear when you drag it in to the scene in play mode? Have you set "play on awake" to true?
Thanks. I don't think I can mark this answer as correct for some reason...
Answer by Ill-Fish · Sep 20, 2016 at 08:08 AM
if your emitter is a child of your GameObject, it will be destroyed in the same moment, when the parent will be destroyed. So, on trigger enter unchild the particle emitter from the parent GameObject and then you can destroy the parent.
Your answer
Follow this Question
Related Questions
Aoe potion with drag and drop? 0 Answers
how to activate a particle when bullet hits a collider? 1 Answer
Unity Spline Particle Emission 0 Answers
How to make a particle effect do damage? 4 Answers