Need a little help understanding data transfer between clients
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on PUN.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
Need a little help understanding data transfer between clients
Foestar
2019-06-15 14:30:00
So I've followed a few tutorials and the guy who did them did an excellent job up to this point. But I don't like copying and pasting code, I prefer to actually learn something from it. And while he has helped me substantially with my transition from UNet to Pun2, I have reached a point that he has explained and either gone over my head, or maybe he didn't explain enough.
At this point I have successfully allowed the player to manipulate the menu, show rooms, create rooms, give themselves a nickname, and show that nickname in a player list when they have entered a room. But I'm having trouble understanding which direction I should go for manipulating objects such as text, or maybe even changing just the sprite on a UI image. His videos explain a bit about RPC's and then he follows up with a little on photon views. But at this point I only know a little of each and have no idea which one I should be using and why. I plan on going back to his videos and rewatching them to see if I missed something.
But right now I was more just looking for someone to explain a bit to me the difference and how to go about changing a images sprite, or updating a text field. From the documentation it seems like I'd have to instantiate the text field for each player to make it an observable object using PhotonView. So does this mean you can't send data from a single UI element that's already in the scene? Or is that possible through RPC's? I know that they can be heavy on traffic for the network.
I'd be grateful for any info on the subject.
Comments
I think it just light bulbed when I was out at the beach. But if I instantiate an object over the network, let's say like a play model/prefab I can have the photonview on it and make it observable so that each client can receive the data of it changing, IE; position, rotation, etc. At least that's what I'm getting out of what I've read and heard in videos at least I think.
So RPC's are like a byte or packet sent out in a queue or order to be received say, the changing of an objects texture?
Anyone?
Okay, so I've got it understood at this point as best I can. But for those who have been struggling with understanding how to go about using PUN 2 as I did whether you're switching from UNet like me or have zero experience with either here is a small explanation that I have found in my short time using this.
Some of the stuff you are gonna do can be done without even sending much information at all. I built my own custom chat setup and have it reading when a player has joined the room and having the chat say that specific player has joined or left. An example of this is as follows:
public override void OnPlayerLeftRoom(Player oldPlayer)
{
ChatBoxField.text += "\n" + oldPlayer + " has left...";
}</div>
Then there are RPC's, which allow me to type into an input field, hit send and have that bit of information sent out as a packet to all other users (or you can send to the host, etc). This is particularly good for setting my game mode from the host and having others get it when they join or when the host changes it.
And finally there are PhotonViews, which I will say I'm not at that stage yet. BUT, it seems rather simple as you instantiate (create) a player over the network and define who that player is owned by. Then all other players can observe it to get its position, rotation, scale, etc.
Back to top