I want this object (script attached) to emit some particles (blood) whenever something enters it. Here’s the code
using UnityEngine;
using System.Collections;
public class Zombie : MonoBehaviour {
void OnCollisionEnter() {
Debug.Log ("ayy");
GameObject zombie = GetComponent<GameObject> ();
GameObject.Destroy (zombie);
GameObject blood = Instantiate(Resources.Load("BloodSplatter")) as GameObject;
ParticleSystem splatter = blood.GetComponent<ParticleSystem>();
splatter.Play ();
Destroy (splatter, 3f);
}
}
The code doesn’t even execute the Debug.Log statement.
The car that touches the zombie has a rigidbody (2D). I tried adding the rigidbody (2D) to the zombie as well, didnt really work.
Solution: OnTriggerEnter2D Since I’m working on a 2D Game