Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by homer_3 · Apr 10, 2016 at 11:47 PM · rigidbodytriggercollision detectionrigidbody-collision

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.

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Guhanesh · Apr 12, 2016 at 03:07 PM 0
Share

http://docs.unity3d.com/$$anonymous$$anual/CollidersOverview.html see collision matrix at the bottom of the page.Hope it may help you.

avatar image homer_3 · Apr 12, 2016 at 03:13 PM 0
Share

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.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

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

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image homer_3 · Apr 11, 2016 at 03:29 AM 0
Share

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.

avatar image JoshuaMcKenzie homer_3 · Apr 13, 2016 at 02:12 PM 0
Share

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

avatar image
0

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

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image homer_3 · Apr 11, 2016 at 11:57 AM 0
Share

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

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

55 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How can I simulate a realistic collision between a metal axe and a door and prevent them from passing through each other? 1 Answer

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges