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 vmadman · Sep 10, 2012 at 06:19 AM · physicsrigidbodygravityparentingattach

Attaching Rigidbody breaks gravity

This question is specific I worry how much help I can get here, but.. just in case.

I've constructing a flying cargo ship. It grabs a cargo box.

The flying ship flies by applying constant upward force. Flies great, everything there is golden.

The cargo container has all the things you might expect, a rigid body, mass, etc.

I attach the cargo container at a certain point using:

 MyContainer.rigidbody.isKinematic = true;
 MyContainer.transform.parent=MyShip.transform;

That works fine too, everything attaches, the ship flies around with the container.

The trouble is that somehow the ship no longer falls to the ground when the engines are turned off (almost as if gravity is completely removed). My suspicion is that the isKinematic setting of the container is messing up the physics of the ship somehow.

If I do not apply isKinematic=true, then the cargo container does not attach at all.. which is strange considering that it becomes parented to the ship.

Again, I know this is specific and I'm not hiring you on, but I thank you even for reading this.

Comment
Add comment · Show 5
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 vmadman · Sep 10, 2012 at 06:55 AM 0
Share

Yes, both have rigid bodies.

It flies using..

 rigidbody.AddRelativeForce( Vector3.up * (gravityForce * enginePower) );

gravityForce is a calculation on the amount of force needed to hover without ascending or descending. enginePower varies from 0 to 2.

However, in my tests of this problem I completely kill the engines, which halts the application of the upward force (which I've verified). It should drop like a rock, but it just suspends in the air. When no container is attached it behaves as expected and plummets.

avatar image vmadman · Sep 10, 2012 at 07:06 AM 0
Share

useGravity is set to true for both the ship and the container and is never affected. rigidbody.is$$anonymous$$inematic is TRUE when grabbed, but is set to FALSE when released. (I think I had it backwards in my code sample above, but changed it)

avatar image vmadman · Sep 10, 2012 at 07:09 AM 0
Share

Also, releasing the container executes the following code.

 $$anonymous$$yContainer.is$$anonymous$$inematic=false;
 $$anonymous$$yContainer.transform.parent=null;

When executed the container will fall, as expected, and the unexpected physics effects on the ship cease.

avatar image vmadman · Sep 10, 2012 at 07:16 AM 0
Share

Ok, I have a suspicion .. I think the grab action may cause 2 colliders to intersect, resulting in strange physics calculations. I am testing now.

avatar image vmadman · Sep 10, 2012 at 07:19 AM 0
Share

If I am wrong I will test your statement about is$$anonymous$$inematic. I've also tested in that direction as well but I will verify again as to not waste your time. In previous tests, is$$anonymous$$inematic=true is required or the box will be parented but will not move with its parent. But, yes, more testing.. thanks for your input.

1 Reply

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

Answer by Fattie · Sep 10, 2012 at 07:52 AM

you're right, it is very confusing, and as is often discussed on this list ...

the specific combinations of what happens when one mixes different types of bodies, is sadly poorly or not documented in the Unity docs.

Just FTR my take ..

  • in this situation never use iKinematic at all

  • the Box should have a rigidbody

  • possibly turn off gravity on the box when it comes a bord

  • likely disable the colliders on the box when it comes a bord

  • possibly set the Box mass to zero (well, low) when it comes a bord

Perhaps no use at all but my take !

Comment
Add comment · Show 3 · 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 vmadman · Sep 10, 2012 at 08:00 AM 0
Share

I will continue my tests on is$$anonymous$$inematic, and you clearly know more about this than I do.. but I'm thinking thats not the issue. Still, your answer hits the mark.. my problem is likely caused by the "clamps" squeezing the box to tightly and causing some physics weirdness. I greatly appreciate your help.

avatar image Fattie · Sep 10, 2012 at 08:04 AM 0
Share

I know nothing! we're all just shooting in the dark - it's so difficult. The huge problem is there are $$anonymous$$ANY $$anonymous$$ANY WAYS to achieve these effects. For example, you could "really" make a small "room" (of colliders) inside your craft, and the box would "really" bounce around in there. Imagine that! That's the "ultimate simulation" method! It sounds like in a way you were TRYING TO DO THAT, but, with touching clamps. touching-pressure basically never works in physics engines, you have to fake it somehow ... exactly what led you to is$$anonymous$$inematic I bet. but that's not right, because is$$anonymous$$inematic essentially does not work at all in any joined situation with the physics engine (of course -- there are many exceptions to this!)

BTW have you considered trying t hinge or other JOINT ? sometimes that is another part of the mix !!!!!!!!!! sorry i could not help more decisively.

avatar image Fattie · Sep 10, 2012 at 08:05 AM 0
Share

don;t forget in a way the cheapest and easiest solution is just make the box have "nothing" - no rigidbody, nothing whatsoever - it's just an image! and stick that on the aircraft ... that's the "cheap, go have lunch" solution! HEH!

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

9 People are following this question.

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

Related Questions

Physics gravity appears very weak 2 Answers

How to make a object jump constantly at y and move to the next position to z (perfectly) 0 Answers

How can I turn on/off Rigidbody.useGravity? 0 Answers

Parenting Rigidbodies to Rigidbodies (Newtonian Space) 0 Answers

How to make rigidbodies on each side of a cube fall towards the cube? [multiple gravity / addForce] 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