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 NikitaChernov · Apr 23, 2017 at 07:37 AM · rotationquaternionverticesrotation axis

Rotation problem

alt text

Hello!

A bit complicated question. I have a problem with rotations. In 3D space there are 2 objects. One of them is parent, and another one is child (like on 1st picture, a rectangle). If we turn parent by axis Y, then child should turn follow parent and stay face to face with parent.

And also if we parent by Axis X (like on 2nd picture), then child should move up and down, but at the same time child should not turn by axis X. Which basically means child should not be looking at parent, just move up or down.

I have already used Quaternion.Inverse(parent.transform.rotation) - in that case rotation X work properly, but rotation Y rotates around its axis, which we DO NOT want.

It's quite complicated, hopefully you understand through my broken english.

rotation-problem.png (31.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 Namey5 · Apr 24, 2017 at 10:36 AM 1
Share

Ordinarily, I would do this kind of thing without parenting. Is the parent-child relationship necessary, or is it simply for movement?

avatar image SohailBukhari · Apr 24, 2017 at 11:36 AM 0
Share

https://docs.unity3d.com/ScriptReference/Transform.LookAt.html

1 Reply

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

Answer by Arycama · Apr 24, 2017 at 11:19 AM

A child transform looking at it's parent will always continue to look at it if the parent is rotated, it is the purpose of parent-child transform relationships.

If you want an object to follow a parent object's position, but not rotation and scale, then do not use a parent-child relationship. Use a script to position the "child" object based on the parents position, and transform.forward.

A script may look like this:

 class FollowObjectRotation : MonoBehaviour
 {
     // Assign this to the "parent" object, in the inspector
     public Transform parent;
 
     // Distance which you want the child to remain from the parent
     public float distance;
 
     void Update()
     {
         transform.position = parent.position + parent.transform.forward * distance;
     }
 }
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

6 People are following this question.

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

Related Questions

Set Rotation on Multiple Axis 1 Answer

Calculating where vertices would be without rotation 1 Answer

Locking rotation makes object spin 0 Answers

Quaternion LookRotation issue 0 Answers

How to turn a character frame independently? 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