How do I instantiate a prefab but it only be seen by one player?

Options

I am working on a two player game. I am trying to have two players in a room. Both players need to instantiate the same prefab that holds playing cards. When I run the game both players instantiate the prefab but I dont want each player to see the others prefab. I am getting a blank prefab that shows up on each device. I have turned of sync but it had no effect. How do I get both players to instantiate the prefab but not see the others? Here is my code:


GameObject go = PhotonNetwork.Instantiate(GameConstants.MASTER_TOWER, Vector3.zero, Quaternion.identity, 0);

      PlayerStats ps = go.GetComponent<PlayerStats>();

      ps.PlayersDeck.Cards = AccountInfo.Deck;

    if(go.GetComponent<PhotonView>().IsMine)

    {

      go.tag = GameConstants.PLAYER_TAG;


    }else

    {

      go.tag = GameConstants.ENEMY_TAG;

      cameraPivot.localRotation = Quaternion.Euler(1 * 180.0f * Vector3.up);


    }


Everything works as expected only I get the other players prefab on both devices. How do I prevent this? Thanks!

Best Answer

  • deaverinc
    deaverinc
    Answer ✓
    Options

    I figured it out on my own. I didnt instantiate the prefab and just made it a part of the scene and populated it with the user data. works great.

Answers

  • deaverinc
    deaverinc
    Answer ✓
    Options

    I figured it out on my own. I didnt instantiate the prefab and just made it a part of the scene and populated it with the user data. works great.