• 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 AmasterAmaster · Jun 12, 2017 at 11:58 PM · camerarotationplayerquaternionminimap

How to align an object's rotation to another GameObject's rotation (without parenting the Objects)

If t$$anonymous$$s question has been answered before, please let me know, as I do not know how to properly word t$$anonymous$$s problem. But I will give it a try.

What I want to do is to align the rotation of a gameobject by reading in the rotation data of another gameobject. The reason for t$$anonymous$$s is to make a mini-map type of camera that has a bird's eye view of the player's position, but parenting would make the camera display very awkward (especially with an orthograp$$anonymous$$c view) due to the player also leaning forward/backward and left/right.

So I settled for an idea of a rotation solution where I would need to set the object's rotation in a way to rotate with the player, but I ran into problems when trying different rotation and quaternion functions. Here are the t$$anonymous$$ngs I have tried so far:

 //myTransform.rotation = new Quaternion(transformToAlignTo.rotation.x, myTransform.rotation.y, myTransform.rotation.z, myTransform.rotation.w);
 //myTransform.localEulerAngles = new Vector3(transformToAlignTo.rotation.x, myTransform.localEulerAngles.y, myTransform.localEulerAngles.z);
 //myTransform.rotation = Quaternion.FromToRotation(Vector3.up * debugSpeed, transform.forward * debugSpeed);
 //myTransform.rotation = Quaternion.FromToRotation(Vector3.up * debugSpeed, transform.forward * debugSpeed);
 
 //myTransform.Rotate(Vector3.right, debugSpeed * Time.deltaTime);
 //myTransform.Rotate(Vector3.right, transformToAlignTo.rotation.x);
 //myTransform.Rotate(0, transformToAlignTo.rotation.y, 0);
 //myTransform.rotation = Quaternion.LookRotation(transformToAlignTo.position);
 //myTransform.rotation = Quaternion.LookRotation(new Vector3(0, 1, 0));
 
 //Vector3 v = myTransform.position - Vector3.up;
 //myTransform.rotation = Quaternion.FromToRotation(transform.up, v);
 
 //myTransform.LookAt(transformToAlignTo.position, Vector3.forward);

So my question is, how can I make the bird's eye view mini-map camera object become aligned with the player object rotation? (As in, When a player turns left or right, the mini-map camera also rotates with up being always the player's forward, if that makes any sense)

Any and all help is appreciated.

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by IgorAherne · Jun 13, 2017 at 01:56 AM

either t$$anonymous$$s or t$$anonymous$$s

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 AmasterAmaster · Jun 13, 2017 at 02:44 AM 0
Share

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

113 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image 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

Quaternion - Euler Angles, weird variable swapping when converting 2 Answers

Rotating a GameObject based on another GameObject's y-axis 1 Answer

Change Player MiniMap Icon 1 Answer

Rotating GameObject Around Player With "Mouse Y" Position 2 Answers

How to add a rotation to this? 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