- Home /
Question by
DLGScript · May 30, 2014 at 12:54 AM ·
networkingmultiplayerrpcnameplayername
Multiplayer - Opposite names above players
I want to know how can I display the player's names above them. This is my script the problem is that the names of the players are opposite
example:
Player_1 = "player 2"
Player_2 = "player 1
the script:
var playerName : String = "";
var screenPos : Vector3;
var labelPos : Transform;
var target : Transform;
function Start () {
if(!networkView.isMine){
CommGO = GameObject.Find("Connection").GetComponent(Masterserverlist);
playerName = CommGO.PlayerName;
}
}
function Update () {
//screenPos = Camera.main.WorldToScreenPoint(labelPos.transform.position);
screenPos = Camera.main.WorldToScreenPoint (labelPos.position);
}
function OnGUI()
{
if(!networkView.isMine){
GUI.Label(new Rect(screenPos.x, Screen.height - screenPos.y, 75, 25), playerName);
}
}
Comment
Answer by Maerig · May 30, 2014 at 01:56 AM
You want to replace
if(!networkView.isMine){
with
if(networkView.isMine){