Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

  • 0
Sign in to follow this  
geckoo

WorldToScreenPoint bug

Question

Hi friends. I use this code to create indicators which show where are the enemies and it works fine. However I have a strange behavior because it also returns a second indicator - exactly the opposite position of an enemy. I explain you. My player is on Vector3 0,0,0 and my enemy at Vector3 4,0,4. So I have an indicator on the enemy (good) but another one which shows me the position -4, 0, -4. I don't understand what it means. Did I a mistake or I forgot something? Have you an idea plz?

 

Please login or register to see this code.

Share this post


Link to post
Share on other sites

6 answers to this question

Recommended Posts


  • 0

(It is possible that I misunderstood your problem)

I made a script for dynamic GUI elements a while ago (still available Please login or register to see this link. ), and I had to deal with this behavior:

L0zRHPM.gif

 

If you have the same issue, just check if the object is actually on the screen. Calculating the camera's frustum will solve the problem.

  • Like 1

Share this post


Link to post
Share on other sites
  • 0

I thank both you for your answer. I have the same issue Roland, but mine shows offscreen where are objects (a tiny sphere on the border). If I compute the camera frustum, I lose this feature ++

Share this post


Link to post
Share on other sites
  • 0

Reading your answers, I had a first understanding about the problem with which I struggled hard. Z must be checked. This second attempt allows to desactivate the indicator when the object is behind the camera. For a 2d project, it could be useful because objects are never behind the camera, but in a 3d project, I should do better :

 

Please login or register to see this code.

 

Share this post


Link to post
Share on other sites
  • 0

This is my third attempt and this is the best way to display indicators which show on screen where are the enemies, also showing offscreen where they are behind the camera by displaying the indicator on the screen borders. I use Z to set the sprite's alpha. The renderer in game is really interesting - something clean and intuitive. Further, using this alternative, the indicator fades out when the player approaches it. I share with you the full script. Thank you for your comments which have helped me ++

Please login or register to see this code.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...