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…

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.

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