- Home /
Using GameObject in place of GUI Window. Need help with coordinates
Hey, I created a GameObject to act as the inventory in my 3D Game. I need to lock the object to act as if it were a GUI Window. As in, always in the same spot on the screen unless the user drags the window to a new spot. Right now I'm trying to use this.
transform.eulerAngles = gameCamera.transform.eulerAngles;
Vector3 camPos = gameCamera.transform.position;
camPos.z -= 2;
transform.position = camPos;
Is there a way to lock it to the camera, so that it looks and behaves like a GUI window? It currently stutters when the camera is moved and moves across the screen when the camera view is changed. Please let me know if I need to clarify anything further. Thanks for reading this and to everyone that helps out!
Answer by robertbu · May 23, 2013 at 11:08 PM
Try putting this code in LateUpate() rather than in Update(). In addition you can do:
transform.rotation = gameCamera.transform.rotation;
Another way to get this functionality is to just make this object a child of the camera. You can either do it ahead of time in the editor, or you can do it dynamically while running.
transform.parent = gameCamera.transform;
Your answer
Follow this Question
Related Questions
Setting parent gives error? 2 Answers
2D gameobject array coordinates 1 Answer
Moving Target Circle 2 Answers
I am getting an error and cant figure out why, Help please? 1 Answer
best way for iron man 2 type holographic in Game GUI 1 Answer