GUI Texture fixed on Object

Good evening,

What it should be in the end is a Texture which changes with the time. So a progress bar projected to the ground for the player to see.
Also my camera just rotates, the position of the player will not change.

With that code the texture rotates with the camera:

the texture on the floor

the texture on the floor

the texture rotates on the floor

the texture rotates on the floor

Basically I want the Texture stay at this point with the rotation clamped.
So when the player moves the camera the Texture stays the exact position and rotation it has in the first picture.
Maybe I just think to complicated… Please help me out here.

Here is my Code:

#pragma strict
 
var toTrack : Transform;
var tex : Texture;
var above : float = 0;  // How much offset from center of toTrack;
var X : float;
var Y : float;

private var rect : Rect;
 
function Start () {
    rect.width = tex.width;
    rect.height = tex.height;
}
 
function OnGUI() {
    var v3Pos = toTrack.position;
    v3Pos.y += above;
    v3Pos = Camera.main.WorldToScreenPoint(v3Pos);
    v3Pos.y = Screen.height - v3Pos.y;  // Convert screen to GUI
 
    rect.x = v3Pos.x - tex.width / 2.0;  // Offset to anchor in the middle
    rect.y = v3Pos.y - tex.height / 2.0;
 
    GUI.DrawTexture(rect, tex);
}

Thanks for your attention and answers, best regards

Nitrosocke - Dennis

Dont use a GUITexture. That stuff is for screen HUD or something similar. Use a 3D text for this

This might also solve a future question that I know you will have

http://wiki.unity3d.com/index.php?title=3DText

Good luck