- Home /
Problem| Player Name Above The Player
Okay I fix it, but now there in another problem: When my friend standing behind me, I can still se his name dysplay on my screen.. This is my new script:
var playerName : String = "Test Player";
var screenPos : Vector3;
var labelPos : Transform;
var target : Transform;
function Update () {
screenPos = Camera.main.WorldToScreenPoint(labelPos.transform.position);
}
function OnGUI()
{
GUI.Label(new Rect(screenPos.x, Screen.height - screenPos.y, 75, 25), target.name);
}
Someone know hos to fix that problem :)?
Answer by Owen-Reynolds · Jul 20, 2013 at 01:39 PM
When your friend is behind you, WorldToScreenPoint will give a negative value for z, which if(screenPos.z>0) GUI.Label(...)
can skip.
First of all, Thanks for reply. Second, It works but now I got another problem: When I'm looking up to the sky, I can see my label name :\ How can I fix it ?
Answer by DLGScript · Jul 21, 2013 at 10:53 AM
First of all, Thanks for reply. Second, It works but now I got another problem: When I'm looking up to the sky, I can see my label name :\ How can I fix it ?
If you don't want to see your name, you could disable it's name renderer for player itself using tags.
Your answer
Follow this Question
Related Questions
Problem with display healthbar and playername above player 0 Answers
networkview + GUI 2 Answers
Can't display PNG texture within GUI calls 1 Answer
Create a custom network manager? 3 Answers
Displaying Z Rotation through script 1 Answer