Player names all displayed as local player photon

using UnityEngine;
using System.Collections;

public class PlayerName : MonoBehaviour {

void OnGUI()
{

     Vector3 offset = new Vector3(0, 3, 0); // height above the target position

      Vector3 point = Camera.main.WorldToScreenPoint(transform.position + offset);
     point.y = Screen.height - point.y;

      GUI.Label(new Rect(point.x - 35, point.y - 20, 200, 20), PhotonNetwork.playerName);

}
}

This script is attacked to the instanced player object which has a photonview attached. The script will display names above all connected users, however the name will be that of player belonging to the local client. i.e. if you connect with the player name “player1”, all players will display “player1” above their heads. Here is a image to illustrate the issue.

GUI.Label(new Rect(point.x - 35, point.y - 20, 200, 20), GetComponent ().owner.name;

:slight_smile:

this is what i did for mine and it works. (Yea i know about a year later…)

public TextMesh text;

// Use this for initialization
void Start () {

	text.text = photonView.owner.name;
}

// Update is called once per frame
void Update () {

}

}