Mattsson almost completed the question. In C# i would...
OnTriggerEnter(Collider other)
{
//assuming your bullet is tagged as bullet and the enemy has no health.
if(other.gameObject.tag == "bullet")
{
Destroy(GetComponent());
}
}
Put this on the same object that the EnemyAI script is!
You can use GetComponent() for many things as shown here: http://docs.unity3d.com/ScriptReference/GameObject.GetComponent.html
Hope This Helps! =D
↧