PhotonNetwork.Instantiate Argument Error.

Hey all, I dont get why this isnt working? I get this error when im trying to build and run the game.

Assets\IslandSpawnManager.cs(24,39): error CS1503: Argument 1: cannot convert from ‘UnityEngine.GameObject’ to ‘string’

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class IslandSpawnManager : Photon.MonoBehaviour
{
    GameStats gameStats;

    public List <GameObject> islandPrefabs = new List<GameObject>();
    public List <Vector3> islandSpawnPoints = new List<Vector3>();

    public int groupOne = 1;


    void Update()
    {
        gameStats = FindObjectOfType<GameStats>();

        if (gameStats.totalIslandSpawns >= 1)
        {
            var randomIsland = Random.Range(0, islandPrefabs.Count);
            var randomSpawnPoint = Random.Range(0, islandSpawnPoints.Count);

            PhotonNetwork.Instantiate(islandPrefabs[randomIsland], islandSpawnPoints[randomSpawnPoint], Quaternion.identity, 0);

            islandSpawnPoints.Remove(islandSpawnPoints[randomSpawnPoint]);
            islandPrefabs.Remove(islandPrefabs[randomIsland]);
            gameStats.totalIslandSpawns -= 1;
        }
    }
}

1 Answer

1

If I change the code to this; it works but then it isnt server wide since im not using PhotonNetwork.Instantiate.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class IslandSpawnManager : Photon.MonoBehaviour
{
    GameStats gameStats;

    public List <GameObject> islandPrefabs = new List<GameObject>();
    public List <GameObject> islandSpawnPoints = new List<GameObject>();

    public int groupOne = 1;


    void Update()
    {
        gameStats = FindObjectOfType<GameStats>();

        if (gameStats.totalIslandSpawns >= 1)
        {
            var randomIsland = Random.Range(0, islandPrefabs.Count);
            var randomSpawnPoint = Random.Range(0, islandSpawnPoints.Count);

            Instantiate(islandPrefabs[randomIsland], islandSpawnPoints[randomSpawnPoint].transform.position, Quaternion.identity);

            islandSpawnPoints.Remove(islandSpawnPoints[randomSpawnPoint]);
            islandPrefabs.Remove(islandPrefabs[randomIsland]);
            gameStats.totalIslandSpawns -= 1;
        }
    }
}