Text name above player's head in Photon

I’ve been ripping hair out trying to figure this out.

Basically, I have a basic Unity game setup with Photon for networking.

Each player spawns with a PlayerPrefab, but I’m trying to put their name above their player prefab, for example. Player 1, Player 2, etc text above an object, or player in this case.

I’ve looked around everywhere but cant quite figure it out, so I’m asking you folks on what would be the fastest, and easiest way to do it?

I don’t have any base code snippets for these, since I’m unsure where to even start.

I really need some help, thanks for reading!

I did this same thing a month ago, what you do is make a 3D Text object and put it as a child of the player prefab. Attach this script to the 3D Text object:

using UnityEngine;
using System.Collections;

public class Nametag : MonoBehaviour {
	void Start () {
		GetComponent<TextMesh>().text = PhotonNetwork.playerName;
	}
}

And it should work.

Dig a little and you will really found many solutions. One of them:

The initial solution by Lancer is not working anymore due to Photon updates. When using Photon 2 you can do the following:

1: As the first solution mentioned you add a 3D text object as a child to the player prefab

2: Create a new C# script and call it SimplePlayerName

3: Add the following code into the script

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;

public class SimplePlayerName : MonoBehaviour
{
    void Start()
    {
        GetComponent<TextMesh>().text = PhotonNetwork.LocalPlayer.NickName;
    }
}

4: Add the script to your 3D text object