Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 marceleh91 · Nov 05, 2015 at 04:45 PM · rotationpositioning

Quaternion to rotate a GameObject and its children

alt textHey, I have a given Quaternion (with the new direction of one GameObject, calles rotation) and 3 GameObjects, where each is a child of the other. I have now by using: GetComponentsInChildren() --> transformObjects (length 3).

Now, I want to change the rotation of the parent with my rotation Quaternion, that is given and also all kids in respect to the parent.

In the case, that I say transformObjects[0].rotation = rotation; It is moving the GameObject far away from the scene and is doing a rotation.

Why, is it moving the GameObject far away, when I use the Quaternion (rotation). And how can I change the postion of the Children in respect to the changes of the parent?

You can see in the picture above, my 3 GameObjects (a finger). My Quaternion is the rotation of the first Part of the fingern. E.g. it can rotate the finger up and the other 2 parts (chirldren) need to move with it.

Can someone help?

unbenannt.png (65.4 kB)
Comment
Add comment · Show 2
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 toromano · Nov 05, 2015 at 06:36 PM 0
Share

So, you are getting parent and children transform components with

 private Component[] transformArray;
 void Start()
 {
  transformArray  = gameobject.GetComponentsInChildren<Transform>()
 }

and changing parents rotation somewhere in your code with

 transformArray[0].rotation = rotation;

and parent gameobject's position and rotation changes? Doesn't make sense. Is it possible for you to provide the code that you manipulate rotation?

avatar image rutter · Nov 05, 2015 at 06:40 PM 0
Share

Children will always move with their parent -- that's how the transform hierarchy works!

I'm not sure if we're understanding your question correctly. You say you want to rotate a parent and its children, but the default behavior when rotating is to do exactly that.

You ask "Why is it moving the GameObject far away?" but that's hard to say without seeing some more information. Either you're doing more than just rotating, or your rotation is around an unusual pivot point.

1 Reply

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

Answer by Levithan6785 · Nov 05, 2015 at 06:36 PM

Anything done to the parent affects the children. If you rotate the parent, the children rotate too. If you scale a parent, it will scale the children. Values changed by the parent does not change values inside the children.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

When creating joints during game play how do you change the position and rotation of an object. 0 Answers

Instantiate GameObject to specific position on the Parent 2 Answers

Offset position to a target 3 Answers

blocks being placed in an odd way 0 Answers

How to position objects UI elements in a line accounting for the rotation of the object 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