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 UltraSage · Apr 22, 2016 at 08:36 PM · physicscollision detectionragdollrigidbody-collision

Collision with rigidbody inside a gameobject

So, I have a ragdoll model with Rigidbody and collider on each bone. All bones are in Armature object, and the armature along with the mesh are in main object (Unity does this by default when importing models).

Now, when I spawn the ragdoll and shoot it, it stops on the wall (that only has mesh collider), but it doesn't seem to register any collisions beyond that. I tried detecting collisions with script attached to the main gameObject via simple onCollisionEnter() function, but it doesn't even print anything out. I thought it's because it's the gameObject that's colliding and it doesn't have any rigidbody or mesh collider (it cannot have, when I add it, the ragdoll stops working for some reason, perhaps it's nesting somehow). I didn't want to attach the detection script to each bone, so I decided to attach the detection script to the player character:

 void onCollisionEnter(Collision col){
     print (col.gameObject.name);
     rogi = col.gameObject.GetComponentsInChildren<Rigidbody> ();
     for (int i = 0; i< rogi.GetLength(0); i++) {
         rogi[i].useGravity = true;
     }
 }

while rogi is a Rigidbody Array, obviously. This, however, doesn't work also. There's no print, and the ragdoll doesn't react anyhow (it's gravity is off by default so it should change on collision). I believe that I should fix the GetComponentsInChildren to getting all the children from the main gameobject since the col would be a children bone, but still - at least there should be a print in console, and there is none. The player character that bears this script has both rigidbody and box collider.

What am I doing wrong here? Do I have to attach the colliders somehow else?

Thanks.

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

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Applying physical restrictions to Mecanim root motion 1 Answer

OnCollisionEnter called before actual collision 0 Answers

How do I solve the Box Collider (3D) Edge / Corner Collisions problem? 5 Answers

Raycast occasionally won't hit colliders on Mecanim animated characters (but hits perfectly if Animator is disabled) 1 Answer

How to get the center of a CapsuleCast or SphereCast on collision 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