- Home /
How do I make gameObject stick in a corner of the screen like GUI
hello
How do I make gameObject stick in a corner of the screen like GUI
I try to do it .... but I cannot control the gameObject position.
var mousePos : Vector3;
var worldPos : Vector3;
function Update () {
mousePos = transform.position;
mousePos.z = 10;
worldPos = Camera.main.ScreenToWorldPoint(mousePos);
transform.localPosition = worldPos;
}
thx....
Answer by DaveA · Oct 28, 2011 at 09:16 PM
http://unity3d.com/support/documentation/ScriptReference/Camera.ScreenToViewportPoint.html
Using viewpoint space, you can put thing, say, at .1,.1 and it will pin them to that corner.
BTW: setting position based on mouse position? that surely won't make it stick anywhere except maybe to the mouse cursor.
Answer by oxium · Oct 29, 2011 at 01:21 AM
just set its transform.parent to be the camera transform (= attach it to the camera)
then set the position accordingly to where you want this object to be
Your answer
Follow this Question
Related Questions
overlap between scenes!!! 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
How to Get Gameobject position on screen resolution that not passed the resolution to set 0 Answers
How to mask gameObject by gameObject 4 Answers
Using script's method from all of the gameobjects that has that script 2 Answers