- Home /
Question by
melvinweert · Oct 13, 2020 at 12:38 PM ·
networkingnoobpun
Photon Nametags
How can I sync the nametags over the network? Since currently some people have the same name of just the default text. Heres my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using TMPro;
public class PlayerNameTag : MonoBehaviourPun
{
public PhotonView PV;
[SerializeField] private TextMeshProUGUI nameText;
// Start is called before the first frame update
void Start()
{;
if (PV.IsMine)
{
SetName();
PV.RPC("SetNameRPC", RpcTarget.All);
}
}
// Update is called once per frame
void SetName() => nameText.text = PhotonNetwork.LocalPlayer.NickName;
[PunRPC]
void SetNameRPC() => nameText.text = PhotonNetwork.NickName;
}
Comment
Hey, did you get an answer, i'm stuck on the same thing. Thank you!
Your answer
Follow this Question
Related Questions
Photon: I call PhotonNetwork.LeaveRoom() but my character doesn't leave 1 Answer
How do I instantiate and set the parent of a Gameobject using Photon? 0 Answers
Trouble using [Command] in a login script for a server. 1 Answer
[PHOTON PUN] Players cant shoot each other? 1 Answer
Unity networking tutorial? 6 Answers