x


Rigidbody Trigger Collider vs. Static Collider no OnTriggerEnter message

According to the Trigger message table here http://unity3d.com/support/documentation/Components/class-BoxCollider.html a Rigidbody with Trigger Collider should get an OnTriggerEnter message sent in all combinations. However, in my case this doesn't work.

I've got a non-kinetic rigidbody with a compound collider (many child objects, each with a trigger box collider). There is no collider on the parent rigidbody object. The rigidbody object passes another object in the scene, with a static box collider (non-trigger). The rigidbody object does not get any OnTriggerEnter message sent. However, I do get OnTriggerEnter message sent if I make the other object's collider a trigger as well.

Is this setup supposed to work?

more ▼

asked May 25 '10 at 11:52 AM

Ivan Leben gravatar image

Ivan Leben
19 1 1 2

Btw, I tested it some more and figured the OnTriggerEnter message gets sent to the child object's with trigger colliders, but not to the parent rigidbody object. Since the message does get sent to the parent compound rigidbody in the case of OnCollisonEnter, I would expect the same to happen with OnTriggerEnter message. Is there a way to make that happen?

May 25 '10 at 12:19 PM Ivan Leben
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

As you said yourself, trigger messages are sent to the object with the collider, not to the Rigidbody - this is because unlike static colliders, triggers are not (AFAIK) treated as compound colliders, so you'll get enter/exit messages for each trigger. To get the messages on the Rigidbody, you could make a simple script to iterate the parent hierarchy, until it finds a Rigidbody, and send the message to that.

more ▼

answered May 25 '10 at 12:53 PM

jonas echterhoff gravatar image

jonas echterhoff ♦♦
9.7k 7 23 102

Yup, that's what I did, it is just a little annoying from the programmer's point of view since you usually want to work with compound colliders on the high level, rather than adding scripts to all the children just so you could handle triggers as well. I'd love a feature added where trigger colliders are treated as compound colliders too.

May 25 '10 at 01:28 PM Ivan Leben

can't you just do findComponentsInChildren and pass them whatever you want the trigger to... trigger?

Nov 13 '12 at 08:14 AM shaystibelman
(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:

x2482
x1781
x980
x83

asked: May 25 '10 at 11:52 AM

Seen: 5320 times

Last Updated: Nov 13 '12 at 08:14 AM