Enemys dont detect collisions with bullet.

i have a box collider and a rigidbody on my enemy yet it doesnt detect collisions. i also have a box collider on my bullet. the bullet is supposed to collide with the enemy then create and explosion and destroy the enemy but it doesnt.

var enemyMoveSpeed : float = 10;

var endOfGamePos : float = -6;

var horizontalRandom : float = 6;

var explosion : GameObject;

function Start () {

transform.position.x += Random.Range(horizontalRandom, -horizontalRandom);

}

function Update () {

transform.position.y -= enemyMoveSpeed * Time.deltaTime;
if (transform.position.y <= endOfGamePos)
Application.LoadLevel("YouLose");

}

function OnTriggerEnter (other : Collider)
{
if (other.tag == “Bullet”)
{
Instantiate(explosion, transform.position, transform.rotation);
Destroy(gameObject);
}
}

I’m assuming your enemy’s collider doesn’t have the isTrigger check box selected in the editor.

OnTriggerEnter is only called if the collider is a trigger.

I would make the collider on the bullet a trigger and move the OnTriggerFunction to a script attached to the enemy.

And use other.tag == “Enemy” instead of other.tag == “Bullet”