- Home /
Enemy wont react to bullets
My enemy AI arnt reacting to my bullet prefab they both have box colliers and heres the code for when the zombie gets hit with the bullet
function OnTriggerEnter (other: Collider) {
if (other.gameObject.CompareTag("Bullet")){
moveSpeed = 0;
}
}
but the bullet just goes through the zombie and the zombie wont do anything what am I doing wrong? (Yes the bullet object has the Bullet tag)
Answer by Meltdown · Jun 23, 2011 at 06:16 PM
Unless your colliders are marked as triggers, this won't work.
You need to use OnCollisionEnter
For moving objects, such as zombies, you don't want to use triggers anyway. You would use triggers on stationary objects such as doors/traps etc.
If that doesn't work, try firing some nukes, that might get a reaction out of them :p
Answer by twoface262 · Jun 23, 2011 at 06:27 PM
I never thought of makeing the colliers triggers >.< lol thanks for the help it worked!