• 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 100307009 · Dec 16, 2012 at 01:54 PM · anglesrelative position

how to find angles and relative position of certain point

Hello. can someone help me with finding relative position (from 0 to 100 or 0 to 1) of the red dot(centre of the spotlight coming from main camera)and the angles(Ox and Oy)that the vector(line maybe) of spotlight makes with the perpendicular of the plane

printscreen

inb4 thanks

Comment
Add comment · Show 3
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 bompi88 · Dec 16, 2012 at 02:23 PM 0
Share

I didn't understand what you are trying to do. Can you please describe it in more detail, and perhaps with more than only a long and hard-to-read sentence. I fell off where you started to describe the red dot.

avatar image 100307009 · Dec 16, 2012 at 04:32 PM 0
Share

http://www.img.by/i/ysD1L.png http://www.img.by/i/L3P6o.png the first one shows a perpendicular to plane(green) at the point I'm pointing and the vector of red dot (red) and Bunny83 already answered how to find that position. Second one is about the angles. I must find alpha and beta, the angles made by green and red bars. a bit confuse

avatar image bompi88 · Dec 16, 2012 at 05:05 PM 0
Share

I suggest something like this your Beta angle (or alpha. couldn't actually deter$$anonymous$$e which was which). : Your raycastcode----

 Vector2 CathetusFromCam = new Vector2(hit.point.x-transform.position.x,hit.point.z-transform.position.z);

 Vector3 Hypotenuse = hit.point-transform.position;

 float BetaDegrees = $$anonymous$$athf.Rad2Deg($$anonymous$$athf.Acos(CathetusFromCam.magnitude/Hypotenuse.magnitude));

1 Reply

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

Answer by Bunny83 · Dec 16, 2012 at 02:47 PM

There are multiple ways:

If you use a MeshCollider for your plane you can easily Raycast against it and you get the uv coordinates of the hit point which is already what you've asked (values between 0 and 1).

If you don't have a MeshCollider or you don't want to use one, you can use the Plane class and raycast against it (with the Raycast function in the plane) to determine the point on the plane. This point however is in worldspace, so you have to use InverseTransformPoint of your object to get the point in local coordinates. Transforming the local point coordinates into 0-100 or 0-1 values depends where the origin of your object is and what scale / size it has.

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.

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

11 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

Related Questions

Shade Based on Normal Map World Position Angle (Updated) 1 Answer

Transform rotation BUG with example 3 Answers

spotlights spot angle 1 Answer

Rotation around z-axis always local space and not world? Vector-axis angle projection calcuations. 0 Answers

Vector3.SignedAngle wrong direction when crossing the 0 point 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