Hello I'm new to multiplayer development and I'm using photon pun 2 in Unity engine C# language. How can I update other players every-time I add another character to my text UI. The characters that was added on the text only appears on my screen only and sometimes just on the screen of another player.

This is my current code for that function. How can I make the text appear on all the players screen.

public Text _letterToShow;
string letter;

 private void OnTriggerEnter2D(Collider2D other)
    if (other.gameObject.CompareTag("Player"))
        letter = other.gameObject.transform.GetChild(2).name;
        _letterToShow.text += letter;

I have already added PhotonView to the _letterToshow Text UI Object. Your Help would be really much appreciated. Thank you

  • \$\begingroup\$ You need to sync the variable to share it with the other clients. Or the method has to be called over the network (see rpc) \$\endgroup\$
    – Zibelas
    Commented Aug 20, 2023 at 10:39
  • \$\begingroup\$ can you share a code example in syncing a variable with other clients? \$\endgroup\$
    – Ryan Cat
    Commented Aug 20, 2023 at 14:02
  • \$\begingroup\$ stackoverflow.com/questions/53430999/… turns up already an answer to that \$\endgroup\$
    – Zibelas
    Commented Aug 20, 2023 at 16:31
  • \$\begingroup\$ Note that if this string can get very long, it may be better to invoke an RPC with just the new character to add, rather than sync the entire string with each addition. \$\endgroup\$
    – DMGregory
    Commented Aug 20, 2023 at 17:24


You must log in to answer this question.

Browse other questions tagged .