I am building a score effect that Instantiates a GUIText at the position where the points where collected. The problem is that I dont know how to convert the GameObjects position (3d) to the GUIText position (2d). Any suggestions?
GUIText uses ViewPort coords, meaning (0.5, 0.5) is the middle of the screen, so use `Camera.main.WorldToViewportPoint(transform.position)` to get the correct coords.
WorldToScreen is correct if you write code for a `GUI.Box`, etc.. which use ScreenCoords (pixels.)
Also, probably don't child to anything, since it will recompute your position next frame using (wrong) worldView numbers.
I prefer using GUIText, since you can add a "live for 4 secs" script, make a prefab and spawn them as needed. Using the in-code GUI.Label version requires you to build and maintain your own List-like data structure.
You could use the function Camera.WorldToScreenPoint to get the position of an object in pixel coordinates (screen coordinates) and then use this values to draw your GUI.
I have tried looking through some tutorials but can not seem to find what I am looking for. Its a pain in the ass looking through youtube videos.
– Mattias-Wargren