Search Unity

Third Party Photon Pun 2 - Instantiate an object without updating its prefab

Discussion in 'Multiplayer' started by ilayasayag, Jul 30, 2021.

  1. ilayasayag

    ilayasayag

    Joined:
    Jul 20, 2021
    Posts:
    4
    hi everyone :)
    I'm right now developing my first Unity Network project and I got stuck in some weird problem:

    my game is a card base game and when I try to instantiate a card(Using PhotonNetwork.ins.. of course) I get a problem -
    I made a cardPrefab for all the cards in the game and gave them 2 basic variables : FaceSprite and BackSprite..
    all of the cards are created when the FaceSprite Is null and before Instantiate a card I change the FacePrefab of the card but On the Client side when I'm creating the cards all of them get the same FacePrefab(In the host part there is no such a problem)

    I think the problem is that they are classified as Clones of the same prefab but I dont really wants to create now 52 different prefabs


    so I have 2 questions:
    1 - how can I make sure everytime I instantiate a card it will be unique;
    2 - how can I sync easly GameObject's Component throw the Network


    thank you guys :)
     
  2. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,735
    You could pass the facesprite and backsprite info in the InstantiationData argument.

    Assuming your facesprites and backsprites are in arrays, you would pass the array indices and then each client will be able to change to the correct sprite in the OnPhotonInstantiate callback.