Name On Top of the players

I'm trying to get the names on top the players

I'm Instantiating the player and the Name (3D Text) separably, I set photonView in both player and 3d text

Then I make the 3Dtext child of the player, for some reason in the game the other players name, they don't move with their players

It't a better way to accomplish this task? or what I'm doing wrong?

Thank you


  • Bankler
    The question is not so Photon related, so it might be better to post it in the Unity forums. But since you already asked, I might as well push you in the right direction. First of all, you probably don't need a separate photonview for the name tag. Since the tag should just tag* along, you can just parent it to the character. That is if you stay with the solution having the name tag in 3D space.

    Another, more common solution is rendering the name tag in 2D. This is how I do it:
    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 - 100, point.y - 20, 200, 20), pawnName.ToString(), nameTagStyle);

    You might have to erase the part: point.y = Screen.height - point.y;
    I have it because my tag's 2D y-position got inverted for some reason that I have not investigated yet.
    showNameTag is a bool to say if it's gonna show or not. pawnName is the name of the character. nameTagStyle is a guiStyle I defined in the editor.

    *pun intended, PUN.. I'm almost killing myself being so funny... :lol:
  • Great Tank you

    Now I have another related question

    I'm using:
    playerName = PhotonNetwork.playerName;

    but all players on my computer have the same name (my player name)
  • Tobias
    /// <summary>
    /// Our local player name
    /// </summary>
    /// <remarks>Setting the name will automatically send it, if connected. Setting null, won't change the name.</remarks>
    public static string playerName

    That field won't help you with the other player's name. The room has a player list. Each Player has it's own name.
    Change your local name and it will change on the other clients as well (if you update the displayed name).