system
July 12, 2011, 9:40am
1
I try to set up a guiText above a gameobject and I realize that the position of one is linked to the position of the other :
oLoader.guiText.transform.position = new Vector2(0.2f, 0.2f);
This code places the guiText correctly but also acts on the gameobject and replace with the same coordinates
oLoader.transform.position = new Vector3(55f, 70f, -85f);
This code places the gameobject correctly in 3D space but guiText’ve been in and out of the screen
Have an idea?
Sorry for my english, GoogleTrad is a good english Friend.
You can use a script from @Eric5h5 called ObjectLabel - click here to access it. It associates a GUIText to some object, and works even if the object moves.
guiText position X range is 0-1 and position Y range 0-1 too.
function Start ()
{
this.transform.position = new Vector3(0.3f,0.7f,1.0f);
}
This code places in the guiText gameobject.
var oLoader : GameObject; // place your guiText
function Start ()
{
oLoader.transform.position = new Vector3(0.5f,0.7f,1.0f);
}
Or you can places this code in a gameObject.
I think it can help you.