Not implemented exception - Photon instantiation error

Hi,

I want to instantiate a crate randomly on the x and z axis and my code works, but not with photon. So none of the players see the same instantiation:

    IEnumerator CrateDrop()
    {
        while (crateCount < 200)
        {
            xPos = Random.Range(50, 390);
            zPos = Random.Range(50, 390);
           Instantiate(crate, new Vector3(xPos, 26, zPos), Quaternion.identity);

            yield return new WaitForSeconds(15);
            crateCount += 1;


        }

    }

This is the working code without photon. and this is how I tried to write it with photon instantiation:

    IEnumerator CrateDrop()
    {
        while (crateCount < 200)
        {
            xPos = Random.Range(50, 390);
            zPos = Random.Range(50, 390);
           PhotonNetwork.Instantiate(crate.name, new Vector3(xPos, 26, zPos), Quaternion.identity);

            yield return new WaitForSeconds(15);
            crateCount += 1;


        }

    }

On play there’s an error:
NotImplementedException: The method or operation is not implemented.
PhotonNetwork.Instantiate (System.String v, UnityEngine.Vector3 position, UnityEngine.Quaternion identity) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs:55)
CrateSpawner+c__Iterator0.MoveNext () (at Assets/Crates/CrateSpawner.cs:51)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
CrateSpawner:Start() (at Assets/Crates/CrateSpawner.cs:22)
Does anybody know what the error means and how to instantiate the crate randomly within the x and z paramters above correctly?

Did you try to add a PhotonView component to your crate and place the crate prefab in the “Resources” folder?

1 Like

Yes the crates all have a photon view and placing them in the resources folder didn’t change anything, the same error occurred…

Solved it. The instantiation code had to be written like this instead and now it works:
GameObject Go = PhotonNetwork.Instantiate(crate.name, new Vector3(xPos, 26, zPos), Quaternion.identity, 0);