How to instantiate a game object correctly in Photon Unity Network?
<p>This code is attached to player prefab and creates 2 objects, in the same spot, which are both visible for all players.</p>
<p>One player can move one of these objects, and can't control the other, and the situation is the opposite for the second player.</p>
<p>How to make it so there is only one instantiated object, which can be controlled (moved around with another script that I have) by all players?</p>
<pre><code>using UnityEngine;
using System.Collections;

public class SpawnGameObjectsNetwork : Photon.MonoBehaviour
{   
    public float secondsBetweenSpawning = 0.1f;
    public float xMinRange = -25.0f;
    public float xMaxRange = 25.0f;
    public float yMinRange = 8.0f;
    public float yMaxRange = 25.0f;
    public float zMinRange = -25.0f;
    public float zMaxRange = 25.0f;
    public float zMinRange2 = 81.0f;
    public float zMaxRange2 = 85.0f;
    public string spawnObjects; 
    Vector3 spawnPosition;
    Vector3 spawnPosition2;

    public float nextSpawnTime;    
    
    void Start ()
    {       
        nextSpawnTime = Time.time+secondsBetweenSpawning;       
    }       
    
    void Update()
    {
        if ( PhotonNetwork.isMasterClient ) 
        {           
            if ( Time.time &gt; nextSpawnTime ) 
            {               
                Vector3 spawnPosition;
                Vector3 spawnPosition2;
                spawnPosition.x = Random.Range (xMinRange, xMaxRange);
                spawnPosition.y = Random.Range (yMinRange, yMaxRange);
                spawnPosition.z = Random.Range (zMinRange, zMaxRange);
                spawnPosition2.x = Random.Range (xMinRange, xMaxRange);
                spawnPosition2.y = Random.Range (yMinRange, yMaxRange);
                spawnPosition2.z = Random.Range (zMinRange2, zMaxRange2); 
                
                GetComponent&lt;PhotonView&gt;().RPC( &quot;MakeThingToSpawn&quot;, PhotonTargets.All, spawnPosition, spawnPosition2 );                 
                nextSpawnTime = Time.time + secondsBetweenSpawning; 
            }      
        }
    }

    [PunRPC]
    void MakeThingToSpawn( Vector3 spawnPosition, Vector3 spawnPosition2 )
    {       
        
            GameObject spawnedObject = PhotonNetwork.Instantiate(spawnObjects, spawnPosition, transform.rotation, 0) as GameObject;
            GameObject spawnedObject2 = PhotonNetwork.Instantiate(spawnObjects, spawnPosition2, transform.rotation, 0) as GameObject;      
    }
}
</code></pre>