- Home /
Want to display guiTexture at the exact position where my ray cast hit to the object
I am using hit.position for the coordinates of the gui texture but still that texture is not displayed on the proper position where I want. I want it at the hit point but its displayed bit away from that and I cant relate that position in my code. Is it possible to display that texture exact on that position and it should not change as player moves. It should stick with the hit point only. And should change as the hit point changes. Please help me
If you move or spin the camera and click more places, you'll see it's often way off, and most times you won't even see anything.
That should help see why $$anonymous$$eet5's reply is the fix.
Answer by meat5000 · Oct 17, 2013 at 02:31 PM
Try this function
http://docs.unity3d.com/Documentation/ScriptReference/Camera.WorldToViewportPoint.html
GUITextures are placed in viewport space, I believe. Get the world point result of the raycast and pass through the function to get a 2D coordinate in Viewport space, which you use to place your texture.
Your answer
Follow this Question
Related Questions
How many ways to stop player from going through walls? 1 Answer
RayCast hit point. 0 Answers
scaling Box (Health) 1 Answer
healthbar with scale 0 Answers
[Photon] Connecting to updated variables 0 Answers