I am very confused.

Options

I am working on a chat system for my FPS game using unity, using entirely Photon PUN. I couldn't seem to find a way to use Photon Chat along with Photon PUN so I just decided to make my own chat system using the tools in PUN.

The problem I am encountering is making a message appear with everyone in a room. The system I have right now works completely fine when not in multiplayer. I just don't know how to make other player's messages sync with each other. The way i have it working right now is a player types what they would like to say into an input field, and then a gameObject is instantiated in a specific position on the screen, and moves up or down when it needs to.

The script that manages everything is a script on a gameObject in a scene where the room takes place. The chat UI is also in the scene. I am having trouble syncing whatever one user types in the InputField with everyone else. I really don't want to remake the entire chat system on the player prefabs, so I am just trying to stick with the system i have. I've tried using RPC's to make it work, but thats where the main part of the problem comes in. How do I access the client's PhotonView and run an RPC to sync it with everyone else when the script I am doing it on is not on the player prefab itself? All of the methods ive used end up collecting a jumble of multiple photonviews, get the wrong views, or do get a photon view, but photon thinks it doesn't exist.

This is by far the most confusing problem i've encountered yet, and I have looked through the documentation countless times to try and solve it.

Does anybody know a method in which i can do this?

Thanks!

Answers

  • Tobias
    Options

    Do yourself a favor and don't use networked objects to show chat messages.

    If you can live with the fact that late joining players can't read old messages, use RPCs or RaiseEvent (which works independent from PhotonViews, so you don't need to access any specific) to exchange the entered string messages. Locally organize your UI to show those.