x


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)

more ▼

asked Jun 23 '11 at 05:49 PM

twoface262 gravatar image

twoface262
129 40 52 55

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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

more ▼

answered Jun 23 '11 at 06:16 PM

Meltdown gravatar image

Meltdown
5.6k 18 25 49

(comments are locked)
10|3000 characters needed characters left

I never thought of makeing the colliers triggers >.< lol thanks for the help it worked!

more ▼

answered Jun 23 '11 at 06:27 PM

twoface262 gravatar image

twoface262
129 40 52 55

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1683
x334
x9

asked: Jun 23 '11 at 05:49 PM

Seen: 648 times

Last Updated: Jun 23 '11 at 06:27 PM