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 PaxNemesis · Mar 06, 2012 at 07:52 PM · rigidbodycollideroncollisionenterchild object

Possible to use child OnCollisionEnter with parent Rigidbody object?

I was wondering if it was possible to use the OnCollisionEnter function on a child of a Rigidbody object, as the compound collider will only get activated once a hit. Using another kinematic rigidbody would not work as I would here need to implement manual collisions to stop objects from continue falling.

Or if that isn't possible, are there any way to detect multiple OnCollisionEnter calls(one for each of the child objects hit). Using collision contact points will only get me the first hit.

I have been looking around, but haven't found any answers that corresponds closely enough to my question to help me. :( Any help would be greatly appreciated. :)

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by DamienSturdy · Mar 06, 2012 at 07:56 PM

Could you use SendMessage() attached to a script on each child, which calls the OnCollisionEnter of the parent object?

Comment
Add comment · Show 5 · 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 PaxNemesis · Mar 07, 2012 at 10:12 AM 0
Share

Hm, not sure how that would help, as it is the parents OnCollisionEnter that is called even if an object collides with a child object. $$anonymous$$y problem would be that I want the childrens own OnCollisionEnter to be called, not the parent one. Or have the parent somehow notice collisions on multiple impact points not necessarily just on the first OnCollisionEnter. :)

avatar image DamienSturdy · Mar 07, 2012 at 10:32 AM 0
Share

If you take a look at the example OnCollisionEnter documents, it itterates through each contact point. Each contact point also provides access to both "this" GameObject and the colliding GameObject. You can then, if you must, use GetComponent and call a function in a script of any of the collided objects.

http://unity3d.com/support/documentation/ScriptReference/Collider.OnCollisionEnter.html

avatar image PaxNemesis · Mar 07, 2012 at 10:49 AM 0
Share

That is true, but it would still only be called one time since a rigidbody makes all the child colliders part of its own. I have been trying to use the contact points in the OnCollisionStay, but I can't get it to work stable enough.

What I'm trying to do is to make objects, like a chair, play a collision sound. As a chair can hit the floor multiple times without leaving the first OnCollisionEnter call the compound collider locking the rigidbody does makes it somewhat challenging.

avatar image DamienSturdy · Mar 07, 2012 at 11:03 AM 1
Share

What you want to do, perhaps, is simply count the number of collisions in OnCollisionStay() and if this count increases, play a sound. You would also play the sound on OnCollisionEnter() (if OnCollisionStay is only called AFTER the initial collision otherwise you'll play the sound twice.) - Should be pretty easy to just use the collision count to do that.

You would probably use velocity to deter$$anonymous$$e the volume of the sound. (Not sure what the best way to do that is off the top of my head- Normally you'd detect a new collision in the collision list and use its normals.)

avatar image PaxNemesis · Mar 07, 2012 at 12:13 PM 0
Share

I think collision point counting might be the solution. I was thinking way to complicated on the OnCollisionStay function. :P The biggest challenge now will be to play the sounds at the right place, but that might not be needed, not sure if people would notice.

Thanks for the help, really appreciated. :D

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

6 People are following this question.

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

Related Questions

OnCollisionEnter not triggering when two rigidbody collide via Instantiate 1 Answer

Which Object Calls OnCollisionEnter()? 3 Answers

Cannot get collision to do anything 1 Answer

Collision Only being detected on one of the objects involved in the collision - C# 0 Answers

simple onCollision and onTrigger problem 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