Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 travellinguncle · Oct 25, 2013 at 09:55 PM · collidertriggerontriggerenteroncollisionenterhierarchy

Inconsistent behaviour in child triggers

Hi, please help!

In my game I have some water with a large box collider and isTrigger set true to represent the sea.

I also have a game object, a helicopter, which has a rigidbody. It has several layers of child objects for various functions. It has a number of colliders and compound colliders in its child objects. The top object with the rigidbody has a script containing OnCollisionEnter to handle physical impacts in any of the colliders and an OntriggerEnter function to handle if the helicopter touches the sea. The physics works fine and the sea trigger also works fine.

Here is where it gets inconsistent:

One of the child objects is a radar which uses a sphere collider with isTriggger set true to monitor the nearby AI helicopters. I have an OnTriggerEnter function in the script attached to the radar object and this works fine. And when the radar sphere trigger hits the sea trigger the radar's OnTriggerEnter runs and handles the event, which is what I want - I don't want my helicopter's top level OntriggerEnter function to run, which causes the helicopter to crash and sink, just because the radar 'field' hit the sea.

But, another child object has a capsule collider for another purpose. It too has isTrigger set true and also has a script attached with an OnTriggerEnter function. When this trigger hits the sea, this 'local' OnTriggerEnter function doesn't run and the event instead passes up to the top level helicopter OnTriggerEnter function which causes it to crash and sink. I know there isn't a problem with the 'local' one since it does run when the trigger hits the terrain.

In effect, these two child objects are structured the same but appear to behave differently. I can fix the offending child by attaching a kinematic rigidbody to it but I don't really see why this is needed for one but not the other. Also, I appear to incur quite a performance hit with this extra rigid body attached.

Any help would be greatly appreciated.

Also, is there a general rule to follow when you need to mix colliders and triggers within an object hierrachy in terms of where you put them and where the trigger/collider functions should go? I thought I was doing alright until this happened!

Comment
Add comment · Show 1
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 skullwolf · Oct 26, 2013 at 03:41 PM 0
Share

I am working on a flying game at the moment. I have child gamobject with collider attached to my plane (isTrigger is turn off on the child so that i can use OnCollisionEnter).

The problem arise when my plane has rigidbody and child collision will affect it (Compound collision). I wanted the child to have non-trigger collision and yet not to affect the rigidbody of my plane.

The only solution I have so far is to unparent the child. Write a script to tell the child to follow the parent.

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by travellinguncle · Oct 06, 2014 at 07:16 PM

OK, I'm back on Unity after a long break. Just answering my own question for the sake of anyone who might stumble upon my question. I've now updated to Unity 4 and without making any changes to the project the inconsistency is gone. Both child objects that contain triggers have to have kinematic rigidbodies to work correctly. After reading further on rigidbodies and colliders and triggers this makes sense to me. It seems there was some sort of inconsistency in the Unity engine that has now been removed.

Comment
Add comment · 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

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

16 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

Related Questions

Character collider falls away unless "isTrigger" selected 1 Answer

Colliders that do not collide... 1 Answer

Colliding two GameObjects 1 Answer

Access other collider without use of Trigger collider. 1 Answer

OnTriggerEnter with exact spot of collision 2 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