I’m trying to destroy an barel if it hits the ground but it’s not working here’s my code:
using UnityEngine;
using System.Collections;
public class Rocket : MonoBehaviour
void OnTriggerEnter2D (Collider2D col)
{
if(col.gameObject.tag == "Ground") //if hit the ground explode... there's two layers "ground" and "nottriggerground"
{
Destroy (gameObject);
}
}
The barrel will roll on a floor and fall into another and then will explode…
But to roll the barrel must be on the ground and if the barrel hit the ground it will explode … Thinking about it I decided to create a layer for each floor.
My barrel will then roll on the floor X and will not explode… when it lands on the ground Y it will explode…
I also wanted to add particles, before being destroyed barrel shows BOOOM particles and then destroy.
[34588-sem+título.jpg|34588]