None Master Client Cant Interact With Objects, Only Master Client Can, HELP!

Options

so i just did a multiplayer game with photon, i did a very simple easy short code when the scene is loaded this is whats going to happen

  public GameObject playerPrefab;

  public GameObject pistolPrefab;

  public float minX;

  public float maxX;

  public float minZ;

  public float maxZ;


  public void Start()

  {

     

    Vector3 randomPosition = new Vector3(Random.Range(minX, minX), Random.Range(1f, 2f), Random.Range(minZ, maxZ));

    PhotonNetwork.Instantiate(playerPrefab.name, randomPosition, Quaternion.identity);


    if(PhotonNetwork.IsMasterClient)

    {

      Debug.Log("u is master");

      Vector3 R2Position = new Vector3(Random.Range(1f, 1f), Random.Range(1f, 1f), Random.Range(0, 0));

      PhotonNetwork.Instantiate(pistolPrefab.name, R2Position, Quaternion.identity);

    }

  }


where i am basically just saying to instantiate the player prefab and to instantiate the pistol prefab only once. the weapon interaction is being synced over the network if the master is only interacting with it, but when a non Clint master try, he will be able to hold it but it will not be synced over the network.


how can i fix this

Comments

  • Tobias
    Options

    You need to transfer ownership of the pistol to the player who picks it up.

    One of the clients is sending the updates of where the pistol is. Initially, the Master Client controls it.