Particle System for Death effect


I’m very new to programming and I was trying out a tutorial on a 2D platformer by

The reason I’m here is because even though I have followed the tutorial, probably, perfectly I still can’t get the result I want.

I’m using a Particle System for the death of my character when triggered by an obstacle (hazard). The code that the tutorial said to add is the bold text: void OnTriggerEnter2D(Collider2D other)

    **Instantiate(Explode, player.transform.position, player.transform.rotation);**
    if (other.tag == "Player")
        player.transform.position = start.position;

and then I made an Empty Game Object in Unity, named it Explode and as the tutorial says, tried to add it to the hazard only to find out that because of the compiler error that doesn’t recognize “Explode” I can’t do anything to the Hazards.

also here’s the tutorial: How to create a 2D platformer for Android in Unity - Part two

Thanks in advance !
Sorry for my bad explanation, as i said I’m new at this.


First look at this (you need to learn how to use unity documentation :)) :

To solve your problem add :

GameObject Explode;

on the beggining of your class, then in Editor drag and drop the object with particles to your script field named Explode (script attached to your game object).