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
1
Question by Rei · Apr 16, 2011 at 01:33 PM · collisionparentchild

How to detect collision on child objects from the parent??

I am trying to write script on the parent object (an "Arm"), as it's animated, the collision volume is on its child mesh (the "Palm") and moves with the palm.

now I have the problem that I can't use OnTrigger or other collision functions from the parent...

I don't want to write a separate script for the palm... Is there a way?

Thank you guys !

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Joshua · Apr 16, 2011 at 01:40 PM

You could just write a really short OnTriggerEnter () script and attach it to all children couldn't you? If you don't want to attach it to all children yourself because there are too many, do it through code. Why don't you want to write a separate script?

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 Rei · Apr 16, 2011 at 11:27 PM 0
Share

em just it looks cleaner to do the code in one script which defines the object... The parent object is in different states, only one of the state will use the OnTrigger function; if I am to separately script on child there needs to be an additional state check too. Just don't seem as clean .. :/

avatar image
0

Answer by VIDesignStudios · Dec 05, 2016 at 07:44 AM

I had the same question. Sadly code is still the answer, but someone wrote a good simple code that can be placed on all children without having to customize or drag anything into it: http://answers.unity3d.com/questions/633480/how-to-detect-child-object-collisions-on-parent.html

Code:

 public class ChildCollider : MonoBehaviour {
         
         //Colliders only register a hit or collision when on the same level as rigidbody or parent. Compound Colliders need to be children. Solution is to add this code to all child colliders: 
         
             void OnCollisionEnter( Collision collision) {
                 this.GetComponent<Collider>().attachedRigidbody.SendMessage("OnCollisionEnter",collision);
             }
         }
 
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

2 People are following this question.

avatar image avatar image

Related Questions

Make a simple tree 1 Answer

How do i kill an "enemy with character controller on + few child objects on" 1 Answer

Getting a Trigger's parent 1 Answer

get the OnCollisionEnter or Stay from the parent? 2 Answers

Ragdoll Collisions and Parent-Child Compenent Affect 0 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