• 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 Sam 5 · Jan 25, 2012 at 03:16 AM · rotationparent-child

Spinning Ball on a string problem (slings, trebuchets etc.)

So I have two objects, parent and child. The parent is spinning using transform.rotate. The child rotates around the parent as the parent rotates because thats how their relationship works. I generalize this idea as like that of a ball on a string. you twirl the string in your hand and the ball spins around it.

If I cut the string (ball.transform.parent = null) my knowledge of physics 101 tells me the ball should continue in a straight line tangential to the rotation. When I attempt this in unity the ball sits perfectly still. It just stops the moment I de-parent it. I throw in some variables and watch the inspector and sure enough, both velocity and angular velocity of the ball while it is a child of the string's anchor = (0,0,0). So what gives? how do I find the world velocity of an object rotating around it's parent? If I could find that I could record that each frame and when I de-parent look up the most recent velocity and just keep using that.

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 syclamoth · Jan 25, 2012 at 03:18 AM 0
Share

Transform.rotate has nothing to do with physics. Your 'ball on a string' analogy isn't really correct, and thinking about it that way can be misleading. If you want it to use physics, use rigidbodies and joints.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Berenger · Jan 28, 2012 at 12:03 AM

As syclamoth is saying, you should use the unity physics scripts like joints. But if you really want to use Rotate, then you need to calculate eache frame the vector v = pos - lastPos, so when string breaks, metaphorically speaking, you can use rigidbody.AddForce( v * someVariable ).

PS : syclamoth, why you never answer in the answer area, it leaves misleading unanswered questions ! I'm sure you're doing this on purpose to trap people :p

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 MidgardSerpent · Jan 28, 2012 at 12:25 AM

Reiterating (and hopefully clarifying) what's been said before.

Parenting an object doesn't create a physics connection... it just keeps the two objects in the same relative positions by changing their transforms.

The best way to do this is to make sure both objects have rigid bodies, then use a fixed joint to represent the "string" ...

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

7 People are following this question.

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

Related Questions

when i make a gameobject child of another gameobject, then it's scale and rotation both changes in a very wierd manner. 0 Answers

Why does the child of a game object not rotate to face mouse position when the parent object is moving? 1 Answer

How to create youtube 360 vr flat cardboard behaviour in unity 2 Answers

Why is a child object not rotating properly with parent? 1 Answer

Why do grouped Terrain objects move together but don't rotate as one? 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