x


OnTriggerEnter - Same collider triggers multiple times?, is size a factor?

I have a collider set as a trigger on my moving rigidbody, which is the size of the rigidbody. I have another trigger, which detects when my rigidbody goes through, and prints the name of the rigidbody collider.

When the rigidbody collider enters the trigger, it prints the rigidbody's name more then once (up to 5 times). But if I reduce the size of the rigidbody collider so that it's much smaller then the trigger checking for it, it only prints the name once.

Does the size of the other collider matter? If the collider entering the trigger is bigger then said trigger, is it going to detect the collision more then once?

Thanks for your time! Stephane

more ▼

asked Jun 04 '12 at 04:45 AM

ronronmx gravatar image

ronronmx
806 84 101 121

After the trigger, are you doing anything in code to end the collision (i.e., removing one of the GameObjects) ?

Jun 11 '12 at 10:14 PM The1nk

@kolban - I wish I had high enough rep, level, whatever it's called on this platform, to upvote that comment. xD

Jun 12 '12 at 01:10 AM The1nk

No I'm not, I just detect OnTriggerEnter() and that's it. I have tried using a bool to tell the trigger that it's been triggered already, but it still happens a minimum of twice.

Jun 13 '12 at 04:49 AM ronronmx
(comments are locked)
10|3000 characters needed characters left

1 answer: sort newest

This is a problem i recently had and asked about and was asked before here is the link to the answer. "Edited from here." here is the chunk of code i have been using with the most up to date version of unity and it seems to be working fine.

function OnTriggerEnter(col : Collider){

if(col.tag == "waypoint" && !isTriggered ){
    isTriggered = true;
    ChangeWayPoint();

}

}

function ChangeWayPoint(){

if(waypoints != 11){
    curWayPoint ++;
    isTriggered= false;
    print(curWayPoint);
more ▼

answered Jun 12 '12 at 04:36 AM

bodec gravatar image

bodec
354 6 13 19

Yes I tried setting a flag like in the example, but like I said above, it still happens twice no matter what I do...weird.

Jun 13 '12 at 04:50 AM ronronmx

Any ideas on this because I have made 6 diiferent checkpoint systems and they all fail from this multiple trigerr thing :( driven me nuts for months coz I thought I was the one doing it wrong fot months :(

Mar 02 at 09:57 PM javanoob
(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:

x5089
x2504
x986

asked: Jun 04 '12 at 04:45 AM

Seen: 1460 times

Last Updated: Mar 02 at 09:57 PM