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 haroonalam · Oct 19, 2012 at 11:23 AM · rotationeuleranglesparenting

How can I change rotation of parent independently without affecting angles and rotation of child ??

hey guys, I have a question about parent rotation independent of child. I have a object A which rotates 360 degree y axis using localEulerAngles, when ever a object B touch object A, A makes B its parent. Now object A moves with B ( in circle) which is absolutely right, but now object B transforms itself to another shape and changes its rotation as well. Is there any solution I can change rotation of parent independently without affecting angles and rotation of child ??

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 Fattie · Oct 19, 2012 at 12:08 PM 0
Share

sheer !!!

well, don't make them parent/childs. or do it the other way around. or make them both the child of something else.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Kryptos · Oct 19, 2012 at 12:38 PM

The purpose of parent/child connection is to have each child dependent of its parent.

So either don't connect them like @Fattie suggested. Or if it is a special operation you can temporarily unparent the child, modify the parent and reparent:

 // Get all direct children
 Transform[] children = new Transform[this.transform.childCount];
 int i = 0;
 foreach(Transform child in this.transform)
 {
     children[i++] = child;
 }

 // Detach
 this.transform.DetachChildren();
 
 // Change parent transform
 this.transform.position = v3NewPosition;
 
 // Reparent
 foreach(Transform child in children)
 {
     child.parent = this.transform;
 }
 
 children = null;
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 Sonaten · Oct 19, 2012 at 03:53 PM 0
Share

This or you could, counter rotate the child. However it would be rather tedious.

avatar image Kryptos · Oct 21, 2012 at 05:45 PM 0
Share

@Sonaten that and it won't be possible if scale was applied to the parent and/or the child.

edit: By "not possible" I meant: "very hard" because the inverse transform i.e. the calculation of an inverse matrix with rotation, translation and scaling is not straightforward.

avatar image Sonaten · Oct 21, 2012 at 05:48 PM 0
Share

True, all the counter messures you would have to take. You should really be clear on the object to object relationship you want when using parenting in your game structure.

avatar image
0

Answer by SeuMadruguinha · May 02, 2020 at 06:32 AM

I found a solution for my case, I wanted to rotate 'A' without rotating 'B':

- Parent A
       - Child B

Solution:
- Parent C
        - Child A
        - Child B

What I did was create a new object C that is the parent of A and B, now with the script on object C I can choose whether I want to rotate only child A without affecting object B or vice versa.

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

12 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

Related Questions

Setting rotation of child GameObject 1 Answer

Is there no way to get reliable angles from a rigidbody? 2 Answers

Problems caused by non-unique Euler angle solutions 1 Answer

Making an objects y Rotation match another objects Z 2 Answers

Instantiating an object in front of the player 3 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