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 /
  • Help Room /
avatar image
0
Question by ComradeVanti · Feb 05, 2016 at 12:35 AM · vector3collider2dlinerendererrotate objectangles

Get angle of two Vector3s

Hello community Here is my situation in 2D Unity: I have a linerenderer. The renderer has two points. I want the linerenderer to have a collider so baseically I make a collider that is big enough and then want to rotate the gameobject it is on by the angle PointA has to PointB.

So for example: PointA = -10, -10, 0 PointB= 10, 10, 0 The angle between them is 45° I wanted to use Vector3.Angle() to get this angle but it always returns a value that is almost 180°. Its never exactly 180° though.

So, does anybody have a solution to this problem and could also explain the reason for this angle-madness to me because I will probably need it again and would like to understand it :D

Thanks in advance

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
Best Answer

Answer by cjdev · Feb 05, 2016 at 12:40 AM

The reason is because the Angle method measures the two vectors as if they were rays starting at the origin and going through the point given. Because 10,10 and -10,-10 are opposite each other relative to the origin the return from the method is 180 degrees.

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 ComradeVanti · Feb 05, 2016 at 12:42 AM 0
Share

@cjdev Thank :) ... so .... how do i fix it? xD

avatar image cjdev · Feb 05, 2016 at 12:59 AM 0
Share

Well honestly I'm not really sure where you're getting 45 degrees from. But in the general case you subtract the offsetting vector to find the vector that starts at the origin in order to measure it against something. In your case I suppose you might be thinking of Angle(B-A, (1,0)) which is the vector from A to B measured against the positive x-axis.

avatar image ComradeVanti · Feb 05, 2016 at 11:04 AM 0
Share

@cjdev Well I get the 45° if i have point A and then want its angle to pointB on the x-axis.... so yeah But i think i have a solution now so thanks alot :D

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

42 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

Related Questions

problem of rotate joint of hands 0 Answers

Collider is not working fine on Line Renderer... 0 Answers

Using ProjectOnPlane to slide around adjacent edges 1 Answer

Vector3 setting condition with the values 0 Answers

How to detect when an object is within an arc? 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