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 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 this question has been answered before, please let me know, as I do not know how to properly word this 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 this 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 orthographic 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 things 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 this or this

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

Neither of these has solved this issue unfortunately... and I will explain my reason. The first one makes sense as I tried it, but it gets a little wonky when it tries to do it's calculations and makes this camera go two places as it tries to realign (making this ghosting as if it were two cameras). It could be my lack of knowledge when it comes down to vector calculations, but it did not work for me. As for the second one (with the Transform.LookAt), it failed due to one thing, it did not rotate with the player rotation, but it did do its job at keeping it facing downward at the player. It is just sad that it locks in that rotation and wont rotate while looking at the player as the player rotates.

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

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

allows users to view 360º content without a VR headset 0 Answers

Player rotates with camera(face same direction as the camera) 1 Answer

Workaround for Quaternion.eulerAngles 360 Degree Limit? 1 Answer

Problem restoring proper camera rotation 1 Answer

How to make camera rotation relative to target. 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