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 Ryder · Jun 14, 2010 at 01:02 AM · physicsobjects

How to conect rigidbodies, and then disconnect them when desired

Hi

When one needs to connect two (or more!) rigidbodies together, and then when needed, "let go" of objects on command, what are the necessary steps? (imagine a fighter aircraft dropping empty fuel tanks...)

It seems to me that there are various things that need to be considered:

-How to connect them to begin with?

-What physics properties must the objects share? (simply both being rigid bodies?)

-When/how to turn on the physics of the object to be released?

Thank you!

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Ryder · Jun 14, 2010 at 05:01 AM

The answer has, as suspected, a few parts.

First, rigidbodies will not normally stay together as the physics engine will act on them independently. To overcome this, on the child rigidbody, select "is Kinematic" in the inspector for the child.

When the appropriate time for release comes, set the isKinematic property to false:

     rigidbody.isKinematic = false; 

Next, to fall off naturally, one has to put the translational and rotational velocities into the child object so that it falls away naturally:

     rigidbody.velocity = transform.parent.rigidbody.velocity;
     angularVelocity = transform.parent.rigidbody.angularVelocity;

When all of that is complete, the child object can be severed from the parent with:

     transform.parent = null;

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
avatar image
0

Answer by qJake · Jun 14, 2010 at 01:16 AM

If you just want one object to follow another one, you don't even have to mess with the Rigidbodies (nor are they required), you can just set the parent of one to be the other. So in your example, you would set the parent of the fuel tank(s) to be the aircraft, and then when you want them to "drop", simply remove the parent-relationship, and the fuel tanks will no longer be "attached" to the plane, and thus, they'll fall.

See the Transform.parent reference for scripting examples on how to parent and de-parent objects. If you want to parent something in the Editor, simply drag an object onto another one in the Hierarchy.

If this isn't what you were looking for, post a comment (not a new answer), and I'll revise my post to help you as best I can.

Comment
Add comment · Show 6 · 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 Ryder · Jun 14, 2010 at 03:39 AM 0
Share

Rigid bodies parented to other rigid bodies don't seem to go together. Their independent physics causes them to go wherever!

avatar image Ryder · Jun 14, 2010 at 04:30 AM 0
Share

Please keep in $$anonymous$$d the title of the question, and the first sentence which both specify that we are dealing with rigidbodies very specifically.

$$anonymous$$y guess is that the rigidbody component of the dropped object will have to somehow be disabled (or non-existant) until the time comes for it to fall away.

Another guess is that it will need to assume the movement and rotation vectors of the parent at the same time.

I think we have a bit to go before we arrive at an answer.

avatar image qJake · Jun 14, 2010 at 05:56 AM 0
Share

Well, you could always disable the gravity or the rigidbody entirely (if you don't need physics). Just set rigidbody.gravity = true or false, or set rigidbody.enabled = true or false.

avatar image Ryder · Jun 14, 2010 at 07:58 AM 0
Share

@ Spike... in the case of gravity, what that would do is simply leave, for a rigidbody, to simply sit in place, see$$anonymous$$gly un$$anonymous$$thered to the parent... not falling, but never the less, effectivly disconnected from the parent (as physics, sans gravity) is still in full effect.

For the example of the fuel tank being dropped, it must of course respond to gravity (and be tied to the aircraft before hand)

And I believe that rigidbody.enabled is an invalid parameter/argument.

avatar image qJake · Jun 14, 2010 at 08:21 AM 0
Share

I did my own quick test, and it seems that if the rigidbody is sleeping (isAwake = false), then it will follow its transform parent around, otherwise not. It's kinda dumb, but I guess I see why that is.

Show more comments
avatar image
0

Answer by richardgengle · Aug 10, 2020 at 09:42 AM

is kinematic looks good, but what if u want to attach a propeller to an airplane?

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

1 Person is following this question.

avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

When dragging a Door open using RIGIDBODYSCRIPT Plays sound. 1 Answer

Instantiating objects as in javascript 1 Answer

Determine Area using code 1 Answer

How to keep physics consistent? 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