I’m using the Photon Viking Demo (from the Asset Store) and a Name display script I found online. The script is doing as it should, but the only problem is that the name of other players does not stay fixed on top of them. I suspect this is an issue with the Camera.main… in the code but I am not sure how to fix it.
Here is the code:
void OnGUI() {
Vector3 offset = new Vector3(0, 1, 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 - 15, point.y + 35, 200, 20), GetComponent<PhotonView> ().owner.name);
}
And here is a pic of what is going on (The 2nd player “Nick” is directly behind “John” but his name is still displayed on screen):