GUILabel follow 3d object

var Health :float;
var MaxHealth :float;
var Healthtexture :Texture2D;

function OnGUI (){
GUI.Label (Rect(100, 100,Health / MaxHealth * 100,20),Healthtexture);
}

i got this as my healbar for a creature in my game but the position is 100, 100… i need to know how to make 3d positions into 2d screenpositions so the healthbar is over my creatures head all the time.?

[URL="http://unity3d.com/support/documentation/ScriptReference/Vector3.html"]Vector3[/URL] screenPos = camera.__[COLOR=blue][URL="http://unity3d.com/support/documentation/ScriptReference/Camera.WorldToScreenPoint.html"]WorldToScreenPoint[/URL][/COLOR]__(target.position);

Ty alot for the quick answar

No problem, make sure you check out the scripting reference http://unity3d.com/support/documentation/ScriptReference/index.html whenever you get stuck.

You can try typing things in like “camera” or “world” or “screen”, you’ll get a fair few results but if you read them all I’m sure it’ll give you a hint of what you need to do.