x


OnTrigger events on multiple objects

I'm having trouble getting an OnTrigger event to work with multiple collisions, whether it be another player or object also in the trigger. Here's my code, I've tried putting it on the trigger and on each player, but it only affects one object:

void OnTriggerStay(Collider other1){
    if(timer > 0)
       timer -= Time.deltaTime;
    if(timer <= 0){
       ApplyDamage(-1);
       timer = cooldown;
    }
}

This is only the function, not all of the variables are included. Everything else works, but the trigger is only working for one object.

more ▼

asked Feb 15 '12 at 02:25 AM

MonkeyAssassin8 gravatar image

MonkeyAssassin8
271 35 38 43

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

1 answer: sort voted first

Make sure your collisions have each at least one non-kinematic rigidbody involved.

more ▼

answered Feb 15 '12 at 03:30 AM

Berenger gravatar image

Berenger
11k 12 19 53

(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:

x980
x321
x290
x72

asked: Feb 15 '12 at 02:25 AM

Seen: 837 times

Last Updated: Feb 15 '12 at 03:30 AM