(Clone) from Instantiated Prefabs over Network

Hi guys, now I have read the answers and that to the (clone) after instantiated objects and have followed them and my solution is semi-correct - it works on the PC but not on the phone… So, I’m building a 2d multiplayer game for android using Photon. So when I test the game, I only have 1 android so I make the phone the master and the pc the client. Now when the user presses the button on the PC the object is initiated without the (clone) after its name, whereas this doesn’t seem to happen on the phone? Iv been at this for a couple of days and I have no clue why this is. Please help!
Thanks in advance for any help given!

Here is my code for reference: public void Player1Button() { player1Activated = true; JoyStickLoading(); thiefCollectorPrefabName = "Thief(Collector)"; RPC_CreatePlayer(thiefCollectorPrefab, thiefCollectorPrefabName, thiefCollectorSpawn); playerControlPannel.SetActive(false); }

So this code here is basically when the user clicks the button, the prefab name is set to Thief(Collector) and then the createplayer method is called which actually initiates the object :

   private void RPC_CreatePlayer(GameObject gameObject, string prefabName, Vector2 spawnVector)
    {
        gameObject = PhotonNetwork.Instantiate(prefabName, spawnVector, Quaternion.identity, 0);
        gameObject.name = prefabName;
    }

Thanks for any help in advance!!

Hi,

from the code snippets above you are not using the RPC the way it’s intended. From the code you are calling the function directly from the Player1Button function. If you want to use RPCs, you have to attach a PhotonView component to the object and use the RPC function of this component. So currently the prefab gets instantiated correctly (which is good so far), but the second part of the function, where you change the name of the object, is just processed on the player who actually pressed the button.

If you want to use PhotonNetwork.Instantiate you don’t have to use a RPC call for this. If you want to change the name of the object, you either have to use a RPC call on the object or use InstantiationData with the PhotonNetwork.Instantiate call. It is the last parameter of the second implementation of that function.

If you want to use RPCs, I recommend you taking a look at this official documentation page.