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
1
Question by Ben · Jun 15, 2010 at 09:01 AM · rotationparentchild

Parent-independent rotation

Is there a simple way to make an object independent of its parent's rotation so that its rotation can be controlled without the parent's rotation affecting it? Here is the code I am using to rotate the child:

myChild.transform.Rotate(0,0,1);
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 fherbst · Jun 15, 2010 at 09:06 AM 0
Share

The idea of parenting is to make the child depend on the parents transform, so your only way to achieve this would be to rotate the child inverse to the parent.

2 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by Tetrad · Jun 20, 2010 at 07:54 PM

You could always store your own Quaternion, do all your rotation on that, and at the end of every frame (i.e. in LateUpdate), set the transform.rotation (which means world rotation) to your Quaternion.

Alternatively, you could write a script that does a "fake" parenting for location. So every frame hammer your object's world position (transform.position) to the parent transform's world position.

Comment
Add comment · Show 1 · 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 Jiell · Nov 25, 2015 at 03:16 PM 0
Share

Can you give an example in code please?

avatar image
2

Answer by _Petroz · Jun 15, 2010 at 09:18 AM

You can use transform.LookAt on the child and it wont be affected by the parent's rotation.

You can also use transform.Rotate( Vector3 axis, float angle ) to rotate around a specified axis, allowing you to compensate for the parent rotation.

Comment
Add comment · Show 1 · 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 drastick · Jun 18, 2012 at 07:31 AM 0
Share

LookAt did the trick for me, I needed my child object to always take the parent translation but I wanted the rotation to always be fixed.

Thanks for the suggestion!

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

1 Person is following this question.

avatar image

Related Questions

Make a simple tree 1 Answer

Changing child's rotation changes parent's position 0 Answers

Need camera to follow player, but not the player's rotation. 13 Answers

Making world rotation of a child object fixed efficiently... 2 Answers

Child/parent rotation problem 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