Search Unity

Third Party Photon: How to get player values loaded to the server?

Discussion in 'Multiplayer' started by Avalin, Oct 16, 2018.

  1. Avalin

    Avalin

    Joined:
    Oct 12, 2018
    Posts:
    98
    Hey I'm sorry for the noob questions,

    I'm usually a Java developer and I'm trying out making my first multiplayer game for Unity. I followed a few tutorials on the subject, and read the documentation, but I'm not sure I grasp entirely how objects are instantiated to the server with all the variables it need.

    Following Photon's tutorial I managed to make movement synchronization in my game, and people can go in and out of the room, yay! The thing is that my players should also be assigned random colors, and at it's current state, each client get a new random color for each player, so if there's 2 players red and yellow on Client 1, those same 2 players are Blue and Black on Client 2. Since color isn't something that will be changed often for the specific, I suppose serialization is overkill? I'm not at all sure how CustomProperties work with Pun2, all tutorials I could find was for Pun1. In Java I remember being able to create objects with all the basic start variables I wanted from the get-go, but in here as I instantiate it seems like that's not as easy?
     
  2. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,735
    Take a look at PhotonView.InstantiationData.

    You can use this to pass setup info which you can access in the OnPhotonInstatiate method and use to configure your game object accordingly.
     
    tobiass and Avalin like this.