Search Unity

How do I set other clients names up with 3d text?

Discussion in 'Multiplayer' started by Durins-Bane, Feb 1, 2017.

  1. Durins-Bane

    Durins-Bane

    Joined:
    Sep 21, 2012
    Posts:
    175
    Im using a syncvar that has each players name in it when they spawn so technically the other players in the local game will have their own names on their characters.

    How do I get the clients to set the other players names that join locally.

    Code (CSharp):
    1.  public void SetPlayerNames(string name) {
    2.  
    3.         //thisPlayers3dName.GetComponent<TextMesh>().text = playerUniqueName;
    4.         if (isLocalPlayer)
    5.         {
    6.             Debug.LogError("SET LOCAL PLAYERS NAME");
    7.             Debug.LogError("SetPlayerNamesforEachlocally " + name);
    8.            
    9.         }else {
    10.          
    11.             Debug.LogError("Shoulve set other players name " + name);
    12.             transform.GetChild(1).GetChild(0).GetComponent<TextMesh>().text = "TEST LOCAL OTHER PLAYERS";
    13.         }
    14.         //myTransform.GetChild(1).GetChild(0).GetComponent<TextMesh>().text = name;
    15.  
    16.     }
     
  2. Durins-Bane

    Durins-Bane

    Joined:
    Sep 21, 2012
    Posts:
    175
    I call that method on Start so if I am thinking about this right.. whenever a new player spawns into the game it should setup every other players name locally above their heads