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 /
This question was closed Jul 17, 2013 at 09:37 PM by rednax20 for the following reason:

I've miss explained my question. I will open a new one tomorrow that explains what I'm asking in better detail sorry for any inconvienice

avatar image
0
Question by rednax20 · Jul 17, 2013 at 05:22 PM · triggerobjectparentchild

Do Child Objects Trigger Parent Objects?

Short and sweet question. I've tried to look it up but I can't find it any where.

if you got this script

 function OnTriggerEnter(){
     print("ouch");
 }

on a parent object, and the child is triggered, will the parents script respond?

are there any places to find this information out.

I think that might be whats going on with my current code but i can't be sure its not something else.

Comment
Add comment · Show 4
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 instruct9r · Jul 17, 2013 at 05:25 PM 0
Share

I dont think the parent will respond on child's trigger collision. If you want the parent to know, that the child is colliding with something, maybe you shoud add a script to the child, that will tell to the parent, that it has something in it's trigger area

avatar image rednax20 · Jul 17, 2013 at 05:30 PM 0
Share

Well I want the parent not to know but I'm basically making a punching game and when I triggered the child object with a punch, the parent object printed ouch. It could be something else but from my observation it seems as thought the parent responded to the child.

note I only have this script on the parent, before anyone asks.

avatar image markedagain · Jul 17, 2013 at 08:06 PM 0
Share

does your parent also have this script attached to it ? i presume the parent also has collision box's. have u tried debugging to see if the script does run twice ? Also be carefull to make sure your coliders are not overlapping

avatar image rednax20 · Jul 17, 2013 at 09:32 PM 0
Share

Okay I just said that my parent is the only one with the script attached.

yes my parent has a collision box

no my colliders are not overlapping

they are not triggering each other!!!

please look at my comment on big bat's answer to see what I was asking.

1 Reply

  • Sort: 
avatar image
1

Answer by bigbat · Jul 17, 2013 at 09:05 PM

If you have Colliders in parent and child objects, you could prevent their collider from undesired triggering each other by using "IsChildOf" function of their Transform component.See this snippet code from unity documentation:

 function OnTriggerEnter (col : Collider) {
     // Ignore trigger events if between this collider and colliders in children
     // i.e. when you have a complex character with multiple triggers colliders.
     if (col.transform.IsChildOf(transform))
         return;
     
     print("Do something here");
 }

where transform refer to Transform component of parent object.

Comment
Add comment · Show 4 · 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 rednax20 · Jul 17, 2013 at 09:29 PM 0
Share

No, see, imagine I have a big cube that has lots of other little cubes spinning around it. The cubes are children of the big cube so when it moves the little cubes move too. when I punch the cube it should explode. i have the explosion script on the big cube

what's happening in my scene is i'm punching the little cubes (that don't have a script attachted to them yet) and the big cube is exploding.

it isn't really a cube thing but I just said that to give you an idea of whats happening.

i don't need to stop them from colliding with each other.

I JUST WANT TO $$anonymous$$NOW IF TRIGGERING A CHILD WILL TRIGGER A PARENT AS WELL!!!!!

on a side note thanks for answering but that's not my problem I guess I should have been more clear with my question.

avatar image markedagain · Jul 17, 2013 at 09:47 PM 1
Share

the simplest answer to your question is no, the trigger of one event wont fire the event of another.

now i think we are still all confused as to how u have this setup. if you want your childs to trigger then they need there own onTrigger events and there own colision box's, im unsure why your parent has the script that the children will use.

p.s. we are trying to help, if we misunderstand your question, du to the lack of example code, please dont get frustrated with us. some ppl might only glance and give advise.

avatar image rednax20 · Jul 17, 2013 at 10:33 PM 0
Share

no I'm sorry its my fault. I sorry if it seemed like i was aggravated. thank you for answering my question it must be something else that is causing my problem. I closed the question because I wasn't clear enough. again my fault. sorry.

due the fact that you have just answered my question I will not be posting another one tomorrow

avatar image markedagain · Jul 17, 2013 at 11:00 PM 0
Share

no worries, and just to re clarify. triggers dont care what object its attached to or what its parent is. they only care if a coliider mesh is present and touched, at this point the object its connected to will only will get the notification as a Event if a script is attached.

also think of it this way, i parent objects in scene for sake of sanity and logic, almost everything has a parent in my scenes, top parent is objLevel, and if i had to manually setup something so that parents dont get notified it would be way to long.

Follow this Question

Answers Answers and Comments

18 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

Related Questions

Make a simple tree 1 Answer

child object to parent c# 1 Answer

Parent Script accessing Child components 1 Answer

Play parent animation without affecting the child animation 1 Answer

OnTriggerEnter not being called with multiple colliders 1 Answer


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