Hello, i am currently working on a simple unity/photon powered multiplayer game.
I have set a script to display player names above the heads of all connected players. The script is as follows:
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 “guest123”, all players will display “guest123” above their heads.
Here is a image to illustrate the issue.