- Home /
move a gui element relative to a 3d objects position?
So I want to make a monster healthbar thats displayed on the gui move when the monster on the screen moves. how can i turn the 3d point into a 2d point on the GUI?
Answer by Eric5h5 · Mar 03, 2010 at 01:05 AM
For a GUITexture object, use Camera.WorldToViewportPoint; have a look at this script on the wiki. (It uses GUIText rather than GUITexture, but can be easily adapted.) If you were using OnGUI, you'd use Camera.WorldToScreenPoint, although you'd have to invert the y, since the screen space in OnGUI uses top-down rather than bottom-up.
Answer by DarkHype · Mar 20, 2010 at 08:19 PM
how did you make the healthbar?
Hey ppl im just asking no need to vote -2!
This is not an answer. Use comments, or better yet, see if this question has been asked, and if not, ask it.
Regarding your edit, sorry, but that's not how the site works. This isn't a forum...ask questions as questions, and post answers as answers. Otherwise you make it less useful for everybody.
also, we have comment form for question. Som you can ask ur question to question starter in that form.
Your answer
![](https://koobas.hobune.stream/wayback/20220612092649im_/https://answers.unity.com/themes/thub/images/avi.jpg)