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 Cambesa · Oct 06, 2016 at 09:21 AM · worldspaceconversionscreenspace

Is there an alternative to Camera.WorldToScreenPoint or another way to solve this problem?

Hi all,

I'm using Camera.main.WorldToScreenPoint to show an image on the canvas based on the user position in world space which is in turn based on the GPS signal. When zooming out, the image of the user disappears when the distance to the Camera get larger than somewhere above 1000. The exact distance varies depending on the supposed vertical location of the user image on the screen.

Does someone know an alternative to Camera.WorldToScreenPoint or another way to solve this problem?

The specific code I use:

Vector3 userToScreen = Camera.main.WorldToScreenPoint(userIndicator); userIndicatorImage.transform.position = userToScreen;

I have looked into using the actual camera and world space matrices but can not come up with the right way to formulate the code to make it work. Can I perhaps see what Unity is doing behind the scenes when I execute Camera.WorldToScreenPoint ?

Kind regards,

Yorick

Comment
Add comment · Show 5
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 Zodiarc · Oct 06, 2016 at 09:26 AM 1
Share

It seems to me more like a camera draw distance issue.

avatar image Cambesa Zodiarc · Oct 06, 2016 at 10:25 AM 0
Share

I thought it would not be a draw distance issue because the image is on the Canvas (which is set to "Screen - space overlay"). But it turned out the WorldToScreenPoint also returned a Z value and it seems that that value has to be below 1000 to make the image appear on the canvas.

I solved the problem by multiplying the Z value by 0.

userToScreen = Vector3.Scale(userToScreen, new Vector3(1, 1, 0));

Thank you very much!

avatar image Namey5 · Oct 06, 2016 at 09:40 AM 1
Share

It could be draw distance related, although I have always had to inverse the Y coords of WorldToScreenPoint to get it to work properly.

avatar image chillersanim · Oct 06, 2016 at 09:53 AM 0
Share

Have ou verified that the user indicator is at the correct position?

avatar image Cambesa chillersanim · Oct 06, 2016 at 10:31 AM 0
Share

I verified it only by looking at it and seeing it placed in the exact spot I expected but there was a secret Z value which caused the issue

0 Replies

· Add your reply
  • Sort: 

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

Conversion from world to screen space not right? 1 Answer

How to render world space objects in screen space using Matrix ? 0 Answers

Worldspace canvas blocking input of Screen Space Overlay Canvas 0 Answers

How to move camera close to a surface such that the pixel size on the surface match the pixel size of the screen? 0 Answers

Dragging panel(prefab) from screen space canvas to world space canvas and scaling to fit 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