Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
3
Question by Reverend-Speed · Sep 26, 2020 at 04:34 AM · rigidbodytransformboxcolliderparent-childmoveposition

Why is my Rigidbody child not moving with it's Rigidbody parent?

I'm sure I've solved this problem before with characters on moving platforms, but nonetheless I'm getting behaviour that's confusing me now.


I have two cubes stacked on top of each other, each with a box collider and rigidbody.


The upper cube is the child of the lower cube. Gravity on both rigidbodies is disabled.


In editor and play mode, moving the parent cube by dragging the transform widget moves the child cube (it inherits the transformation).


However, when I run the following simple test code on the parent (moving it with movePosition), the child cube remains motionless, failing to inherit the transformation of the parent.

 private Rigidbody rb;
 
     public float percent = 0.0f;
     void Awake()
     {
         rb = GetComponent<Rigidbody>();
     }
     void Update()
     {
         percent += Time.deltaTime;
         rb.MovePosition(Vector3.MoveTowards(Vector3.up * 2 + Vector3.left * 4, Vector3.up * 2 + Vector3.right * 4, percent));
     }

As I say, I'm certain I've used something similar for characters and moving platforms before (parenting onCollisionEnter etc.)


What's the obvious thing that I'm missing here? This shouldn't be confusing me like it is...!

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by SlowCircuit · Sep 26, 2020 at 05:20 AM

Rigidbodies do not inherit forces/velocity from parent rigidbodies. They act independently. You could apply the move position to both, but there's always the possibility that the child will hit the parent when trying to do that. You could use FixedJoint to keep them together (might need to unchild it), but it depends on what you're trying to accomplish. FixedJoint would really keep them together, but if you want the child to also be able to move on it's own but move with the parent as well, then you might want to take a look at other joint types and see what works best for what you want.

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 Reverend-Speed · Sep 26, 2020 at 12:57 PM 0
Share

Hi @SlowCircuit ! That seems to contradict the docs, though, no?


Parenting When an object is under physics control, it moves semi-independently of the way its transform parents move. If you move any parents, they will pull the Rigidbody child along with them. However, the Rigidbodies will still fall down due to gravity and react to collision events.


Not sure FixedJoint is going to help much as I want the child to move horizontally independently of the parent. So odd, though, I could have sworn I had similar behaviour working with a character standing on a moving platform...


Ach, to confess, I thought this would be a straightforward issue and it was getting late, so I just posted and hit the hay. =) I'll do some more research here. Thanks for your time!

avatar image SlowCircuit Reverend-Speed · Sep 26, 2020 at 08:06 PM 0
Share

The doc is confusingly worded. I believe it's saying if you move the parent's transform it will move the child's transform as well, but moving the parent rigidbody will not move the child's rigidbody. You can google "unity parent rigidbody not moving child" and you'll find a lot of people with similar issues to you who also have a rigidbody on the child. For what you describe I'd do my first suggestion. Keep it childed. On the parent, assign the child rigidbody in the inspector. Then when you add forces to the parent, add them to the child too. It should work well for what you're trying to accomplish.

avatar image indie6 · Nov 13, 2021 at 05:56 PM 0
Share

You are correct, rigidbodies always act independently. Here's a post from Edy's vehicle physics: https://forum.unity.com/threads/child-rigidbody-doesnt-act-normally-when-parent-rigidbody-moves.564991/#post-3754306

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

212 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 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 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 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 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 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 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 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 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 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

Collision not working as intended with rb.MovePosition 0 Answers

Rigidbody.MovePosition relativeTo parent 0 Answers

How to use MovePosition with a parented rigidbody? 1 Answer

RigidBody2D - Ignoring other RigidBodies. 1 Answer

Get direction of moving sphere? 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