Search Unity

Photon, player name over the character?

Discussion in 'Scripting' started by ESCPE, Apr 27, 2015.

  1. ESCPE

    ESCPE

    Joined:
    Jun 12, 2013
    Posts:
    40
    So i've been working on this problem for a while and now i just want it over with.
    Basiclly what i want is the playername over the head, i got a script but i have no idea how i should do it

    Here is my script, i have tried alot but nothing is working so the code down below may be messed up.
    If you could help me out i will hugely appreciate it since it's for my schoolproject.

    Thanks!

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.UI;
    4.  
    5. public class NameTag : Photon.MonoBehaviour {
    6.    
    7.  
    8.     Text text;
    9.     string nameTag;
    10.    
    11.     // Use this for initialization
    12.     void Start () {
    13.     text = GetComponent<Text>();
    14.    
    15.    
    16.     PhotonNetwork.player.name = PlayerPrefs.GetString("NameTag");
    17.     if(photonView.isMine)
    18.     {
    19.     text.text = photonView.owner.name;
    20.     photonView.RPC("SendName",PhotonTargets.OthersBuffered,name);
    21.     }
    22.     //SendName(nameTag);
    23.    
    24.    
    25.  
    26.  
    27.     }
    28.    
    29.     // Update is called once per frame
    30.     void Update () {
    31.     }
    32.    
    33.     void SendName(string name)
    34.     {
    35.     name = PhotonNetwork.player.name;
    36.     }
    37.    
    38. }