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 xaxum · Dec 16, 2010 at 04:00 AM · gameobjectsanglesdegrees

Getting angle, 0-359, between two game objects

I can't seem to figure out how to get the angle between two game objects. I need the angle on the X,Y plane and the X,Z plane. I was trying transform.eulerAngles.y and transform.eulerAngles.z but there are scenarios where that does not work because if you go around 180 on XZ and then 180 on XY the XZ should be 0 but it stays at 180. What is the best way to get the correct degrees between the two game objects all the time no matter how many times you rotate around the object.

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 cregox · Sep 21, 2011 at 06:42 PM 0
Share

late related: http://answers.unity3d.com/questions/162177/vector2angles-direction.html

2 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by Eric5h5 · Dec 16, 2010 at 04:29 AM

Quaternion.Angle

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 xaxum · Dec 16, 2010 at 08:39 PM 0
Share

This seems to only do between 0 and 179.9 degrees and still has the issue where if you go 180 on one axis and then 180 on another and start moving along the first axis again it does not reset back to zero and ins$$anonymous$$d starts at 180.

avatar image
1

Answer by alireza khodakarami · May 16, 2011 at 02:17 PM

It's a known Isue from early days of 3D animation software development called "gimbal lock" the basic concept is when you rotate on one axis and then try another one, the order is important because sometimes the local rotational axis will be on top of each other and no matter which one you rotate, the object will rotate the same, so, different programs found different solutions for this problem, I think maybe the problem you are face to face is the approach of unity to solve gimbal lock.

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 syclamoth · Sep 22, 2011 at 01:32 AM 0
Share

Unity tends to use Quaternions to avoit gimbal lock- except, that quaternions don't really respond well to interpretation by real numbers! You might want to have a look at Atan2 or the like- they might have the solution for this one.

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

2 People are following this question.

avatar image avatar image

Related Questions

How to check object "rotated" X degrees 1 Answer

Setting Vector3.angle between two gameObjects 2 Answers

Having Physics.Raycast rotate with the gameObject 2 Answers

Trying to obtain sine/cosine by angles giving me imprecise values 1 Answer

Quick Angles Question 2 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