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 reberk · Nov 25, 2013 at 05:35 PM · rigidbodychildrenparentingpivot

Move parent pivot point along with child Rigidbody?

I've constructed a shopping cart vehicle with a rigidbody attached. What I'd like to be able to do is, when stopped, pivot around the spot where the player wound stand were they pushing it. I can accomplish this by making the shopping cart a child of an empty gameobject (which serves as a pivot point), which I can then rotate to get the desired effect. The only problem with this is that this parent doesn't come along with the cart once it's moved from its starting point! This of course leads to some very strange rotation behaviour.

There's probably something simple I'm overlooking, but I would very much appreciate any insights into this issue.

Comment
Add comment · Show 4
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 Key_Less · Nov 25, 2013 at 05:59 PM 0
Share

You could try making the pivot point a child of the shopping cart and offset it's local position. That way, any time the shopping cart is moved, the pivot point will move with it.

avatar image reberk Key_Less · Nov 25, 2013 at 06:03 PM 0
Share

Thank you for your response. The question that your solution leads me to is how I would go about achieving the pivot in that case. With the pivot as parent, I can just rotate its transform (or rotate simply through script), but with the pivot as child, I'm not sure how to approach that.

avatar image reberk Key_Less · Nov 25, 2013 at 08:34 PM 0
Share

This is exactly what I needed, thank you! I wasn't aware of RotateAround, which I will certainly stow in my bag of tricks for the future.

Also, if you can convert your comment to an answer, I'll be able to check off "accept this answer as correct" for easier reading if anyone stumbles across this.

avatar image Key_Less Key_Less · Nov 25, 2013 at 10:07 PM 0
Share

Perfect, I'm glad I could help.

1 Reply

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

Answer by Key_Less · Nov 25, 2013 at 06:36 PM

Ah, I see now, sorry I read the original question incorrectly. You're using this pivot point to rotate the shopping cart object, not the camera.

Okay, so I would suggest still keeping the pivot point as a child object, so it will always translate with the shopping cart. Then you can use the pivot point for your rotation calculations;

Try something like this:

 // Get the transform from the child object, pivot point.
 var pivot = transform.FindChild("PivotPoint");
     
 // Rotate the shopping cart around the pivot point's position.
 transform.RotateAround(pivot.position, Vector3.up, 20 * Time.deltaTime);

I haven't been able to test this but I'm hoping it can lead you in the right direction.

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

17 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

Related Questions

Instantiate an object as a child of the gameobject's parent 2 Answers

How to make an Instantiated prefab a Child of a gameobject that already exists in the hierarchy 3 Answers

Extreme slowdown during move request 1 Answer

VR Rigidbody not working with child colliders 0 Answers

Animated character with simple colliders on joints - rigidbody not finding child colliders. 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