- Home /
OnTriggerEnter not called on rigidbody?
I have 2 objects. 1 with just a trigger box collider and 1 with a trigger box collider and a rigidbody. When the collide, only the object without the rigidbody is notified. Is that how it's supposed to work? I thought whoever had the rigidbody was the one that was supposed to get notified.
http://docs.unity3d.com/$$anonymous$$anual/CollidersOverview.html see collision matrix at the bottom of the page.Hope it may help you.
The matrix only shows that an event fires but not who receives the event. The trigger event is firing, but I'm pretty sure the rigidity should be the one receiving it. Not the static collider, which is what's happening.
Answer by JoshuaMcKenzie · Apr 11, 2016 at 03:25 AM
Actually both objects should raise notifications
My assumption is that you are moving or enabling/disabling the trigger thats without the rigidbody. Since its without a rigidbody the physics system classifies it as a Static collider and thus does some optimizations to help with performance. however that means the physics systems is operating under the assumption that it never moves nor is ever enabled/disabled. doing so can cause unintended behaviour.
if you want the other trigger to move then you likely want for it to be a Kinematic Rigidbody collider and set as a trigger
No, I'm moving the object that has the rigidbody. The object that only has a trigger collider is staying still and it is the one receiving the OnTriggerEnter notification. I've tried making the rigidbody kinematic and not kinematic. Neither results in the rigidbody getting the notification.
if both colliders are triggers, then both will raise a OnTriggerEnter event at the same time.
make sure they are set to collide with each other (via the collision matirx). and that the gameobjects with the colliders have their collision layers set. Since at least one of them is getting the event then its likely not to do with the collision layers, but there is a possibility that your not colliding into the other trigger but something else completely different.
make sure the script (the one that is not firing) has the function name OnTriggerEnter spelled correctly and that the script inherits from $$anonymous$$onobehaviour, and that the script is on the same gameobject that has the trigger collider. If you put the script on a parent or child object and not the exact object with the collider, then the gameobject won't tell the script to run the OnTriggerEnter for that script.
If this still doesn't help then obviously something else is the culprit, try attaching a screen shot of the two objects and their inspectors, so we can see what is going on. Also posting the functions you're expecting to be called will also help
Answer by ankush20 · Apr 11, 2016 at 05:21 AM
Hello homer_3,
On which object your script is attached "to the one with rigidbody" or "to the one without rigidbody"? if the script is attached to the one with rigidbody, the event OnTriggerEnter calls on that object only. Please check and let me know.
Thanks Ankush Taneja
A script is on each object. That's how I'm able to tell that one is getting the event and the other isn't.
Your answer
Follow this Question
Related Questions
Rigidbody Precise Colliders 1 Answer
OnTriggerEnter works just once without Rigidbody. 2 Answers
Colliding with multiple objects 1 Answer
Box collider triggers interfering with rigidbody movement 3 Answers