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
1
Question by Mcg · Dec 12, 2016 at 08:17 AM · camerauiworldtoscreenpoint

Using WorldToScreenPoint to account for a perspective camera, angle and position?

Hi , I'm having issues with aligning a cross hair to a vector3 which is a target lead position using WorldToScreenPoint however my player camera is in perspective and the position and angle seems to offset the alignment like in the image below.

I currently use my player transform to lookAt the target lead vector3 and use it's forward direction * distance to set the crosshair in the top example on the screenshot but I use the vector3 of the target lead position in the second.

Is there a way I can account for the camera position,angle to make it more accurate so I can use my player transform forward direction as a crosshair?

Thanks

alt text

worldtoscreenperspective.jpg (137.0 kB)
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

2 Replies

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

Answer by Mcg · Dec 14, 2016 at 02:55 PM

Hi @Artaani I currently just have the one camera and have tried reducing the distance of the clipping planes but the problem reoccurs only when I'm modifying the camera position.

I've also tried un-parenting the camera but the issue still occurs unless I set the camera position to vector3.zero

Edit

I found that my prediction lead pos from the crosshair gui and noticed it's slightly out of sync which is causing the angle created when modifying the camera position.

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

Answer by Artaani · Dec 13, 2016 at 10:22 AM

It should consider camera rotation and FoW by default.

Do you have only one camera, or several? Maybe you use WorldToScreenPoint for a wrong camera? For example if you use it as Camera.main.WorldToScreenPoint, maybe your camera does not have "MainCamera" tag.

Or maybe it happens due too large distance between clipping planes. 0.1 - 50000 it is too much. It may start to cause rendering problems due precision of floating point. Try to decrease far clipping plane to 5000 or 1000 for testing.

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.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

UI element attached to Camera Coordinates 2 Answers

Move camera between canvases in UI menu 0 Answers

WorldToScreenPoint creates DOUBLE ui 1 Answer

OnMouseDown raycast doesnt match UI crosshair 1 Answer

Place GameObject's rect 0 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