• 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 Kaji-Atsushi · Apr 28, 2015 at 07:04 PM · physicsrigidbodyparentchildmoveposition

Is it possible to prevent parent rigidbody physics from effecting children rigidbodies?

Basically, I'm asking if it's possible to move a parent object with the rigidbody component without effecting it's child's rigidbody physics. While keeping the child's physics properties.

I have it setup where I have the Parent Rigidbody game object, contain a child rigidbody object and a series of springs connected to that child rigidbody.

So if i move that parent game object using Rigidbody.MovePosition(). The child object would be springing around accordingly based on how the parent is moved.

But I actually don't want the parent's movement to be effecting the child's physics.

That can actually be accomplished if i move the parent game object using transform.position. This would actually move the parent game object without causing the child objects to spring around. HOWEVER....a new problem arises. High speed collisions with my objects would no longer be reliable, because im using transform.position, instead of rigidbody.MovePosition.

Since my game requires solid and reliable high speed collision detection, I had the Parent game object have a rigidbody component with collision detection set on continuous, including all child and other objects.

So I'm in a bit of a conundrum here... Method One: I get proper high-speed collisions, but unwanted physics movements of my child objects. Method Two: I get bad high-speed collisions, but correct physics movements of my child objects.

I was hoping there was just some simple line of code I could right to just 'Disable transferring physics' to child objects. but....there isn't.

I would have thought that it should be fairly common for some objects to have seperate physics reactions in children.

Any tips would be great, thanks!

Take a look at this video to see what I mean...(Forgive my placeholder graphics).

https://www.dropbox.com/s/066rhgjn3uh3os3/ParentRigidbody.mov?dl=0

What's going on here is that when I move the red circle around the two boxes are supposed to move and rotate in a specific way.

In the first half of the video, it moves but with a lot of bounce and spring, because it has a child object which has the box attach to some springs. Here I'm using rigidbody.moveposition.

In the second half of the video, it moves nice and swiftly following the red circle like it's supposed to. And the box actually still has it's springy physics if another rigidbody object were to collide or bounce on it....The only downside to this is that, because I'm using transform.position instead of rigidbody.moveposition. My collisions aren't reliable, high speed objects fall through them, etc....

Comment
Add comment · Show 1
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 2d4Games · Apr 28, 2015 at 07:08 PM 0
Share

Why exactly does the child object need to be parented to the parent object in the first place? The springs should move the child object around regardless of its parenting. Or, if it's absolutely essential that the object be parented, you could just disable the springs before moving the parent object, move it, and then re-enable the springs.

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Bunny83 · Apr 28, 2015 at 07:44 PM

You should never parent a rigidbody to any object that itself is moving. Rigidbodies are simulated in worldspace. If you parent a rigidbody to another moving object the childs physics will get messed up.

Also a parent-child relation ship always includes that the childs are affected by everything that happens to the parent. If you don't want this, don't parent them together.

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 SacredSticks · Jul 06 at 07:42 AM

I recognize that this is a very old problem, but I saw that there is no actual solution, only an explanation of the problem. I was having the same issue and this explanation was very useful for me to solve it, and I thought I would share just in case others discover this issue later.

Let's say Object A is a parent to Object B, both of which are physics based. Add a child to A called "B Position" and make B a root object in the scene. Then you can just attach this script to B. You don't need to worry about positioning B Position in the right place, it'll automatically be moved to B in the start method, and then in every frame B gets teleported to B Position's position and rotation.

Edit for clarification: Put B as a child of an empty (B Parent), and put this script onto B Parent. It'll end simulating a parent child relationship of [A -> B Position and B Parent -> B] where B Position and B Parent share transform data.

     [SerializeField] Transform target;

     private void Start()
     {
         target.transform.position = transform.position;
         target.transform.rotation = transform.rotation;
     }
 
     private void Update()
     {
         transform.position = target.position;
         transform.rotation = target.rotation;
     }
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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

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

Related Questions

Child rigidbody clipping through walls. 2 Answers

Make a simple tree 1 Answer

Child rigidbody acting strange when moving parent. 0 Answers

" You should never have a parent and child rigidbody together " ? 2 Answers

Child Gameobjects are not fixed to the parent when using physics 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