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 Brokenarrow · Jun 11, 2013 at 06:05 AM · collisionphysicsrigidbodychildkinematic

Child Rigid Body collision problem

Hi, I've run across a weird problem lately which I'm unable to resolve myself.

My goal is to create multiple cars which each consists of 2 objects, front and back.

-The front and back are supposed to detect collision. (but different colliders!)

-The front isn't suppose to be affected by physics, the back is.

-The front is also supposed to come of at a certain point, and then react normally to physics.

-The front part has to move perfectly with the back part until it comes of.

The thing is, I can't figure out how. Solutions I've tried:

  1. If I lock the child rigid body in local space(either with code or with the kinematic check-box), it will stop detecting collision with other child rigid bodies(other car fronts) in the scene.

  2. If I remove the rigid body component but still lock the child into place, collision will look normal, but collision will not be detected.

  3. If I make the front object a child with a rigid body, but without the lock, it will work properly, but obviously react separately to physics when compared to the parent.

Edit:

  1. Two colliders with a rigid body as parent doesn't work either, unless there is some way to differentiate between colliders by code, as both colliders send their data to the parent rigid body(whilst I aim to to have different effects on the back and front).

  2. Two rigid bodies attached by a Fixed Joint almost does the trick, except that joints allow for some degree of movement between the bodies. Also joints require two non kinematic rigid bodies...which means the front will always be affected by physics.. :(

I'm not sure what to do at this point.. I'm thinking its not possible actually, as it would probably require collision of two kinematic rigid bodies..

Any tips or suggestions for alternative routes to the same result 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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by fafase · Jun 11, 2013 at 06:27 AM

Add en empty game object and put all of your colliders as children. Now put the rigidbody on the parent object (the empty one you created).

When you want to separate them, just unparent the object:

 transform.parent = null;

and it will go on its own.

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 Brokenarrow · Jun 11, 2013 at 10:39 AM 0
Share

Problem with this setup is, that it seem to detect all collision on the parent empty game object, ins$$anonymous$$d separately on the front and back..pity because it looked very promising

Thanks for the suggestion though!

avatar image
0

Answer by Some_weirdGuy · Oct 06, 2013 at 08:27 AM

(been a few months and you probably have this solved/found other methods, but for any who have a similar question and see this: )

This code will give the desired functionality of detecting child colliders:

 void OnCollisionEnter(Collision other){
         ContactPoint contact = other.contacts[0];
         print(gameObject.name +" got collided from contact " + contact.otherCollider);
 }

collision(unfortunately means it won't work with triggers) contains a contacts variable:

http://docs.unity3d.com/Documentation/ScriptReference/Collision-contacts.html

http://docs.unity3d.com/Documentation/ScriptReference/ContactPoint.html

you can then retrieve the first contact( contacts[0] ), and check the 'otherCollider' variable it contains, to get the specific collider that made contact(in this case, the child object's collider).

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

Realistic collisions with a kinematic rigidbody? 1 Answer

2D motion/collision: physics, or direct translation? 2 Answers

Are my kinematic rigidbodies slowing my scene down? 2 Answers

Preventing objects from intersecting with minimal physics 3 Answers

Disable rigidbody from being able to move other rigidbodies 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