PhotonNetwork.Instantiate

Im trying to get the enemys to sync on all players screen when they spawn but im coming across an error. I fully understand the error and why it is happening im just not sure how to fix it. I dont like posting my whole script but here it goes

using UnityEngine;
using System.Collections;
public class ZombieSpawn : Photon.MonoBehaviour {
    private float minRepeatRate = 1f;        //Lowest Random Spawn Rate (Keep at 1 for best results)
    private float maxRepeatRate = 1000f;    //Highest Random Spawn Rate (Will increase random spawning time if decreased and will decrease random spawning time if inscreased)
    public float spawnTime = 15;             //Time Before Enemies Spawn
    public float repeatRate;                //
    private float furthestDistance = 0.0f;    //Finds Furthest Distance from player
    private float distance = 0.0f;            //Find all Disrances from player
    public Transform[] SpawnPoints;            //Holds All Spawn Location information
    private Transform furthestSpawnPoint;    //Holds Position of the current Furthest Spawn Location
    private Transform PlayerTransform;        //Holds Players position
    public GameObject[] Zombie;            //Array of Enemies to spawn, Add as many different enemies you want to spawn in the Inspector area.
    void Update ()
    { 
        repeatRate = Random.Range (minRepeatRate, maxRepeatRate);    //Randomizes Repeat rates
        if (repeatRate <= 1.74)                                     // Increase This To Spawn Enemys Faster
        {
            Invoke ("SpawnEnemy", spawnTime);                        // Spawn Enemy
        }
    }
    [PunRPC]
    void SpawnEnemy()
    {
        PlayerTransform = GameObject.FindWithTag("Player").transform;     // Gets Current Players Transform
        foreach(Transform point in SpawnPoints)                            // Stores Distances from player to spawnpoints
        {
            distance = Vector3.Distance(PlayerTransform.position, point.position);
            if (distance > furthestDistance)
            {
                furthestDistance = distance;
                furthestSpawnPoint = point;
            }
        }
        int enemyIndex = Random.Range (0, Zombie.Length);                // Picks a random Enemy
        PhotonNetwork.Instantiate (Zombie[enemyIndex], furthestSpawnPoint.position, furthestSpawnPoint.rotation, 3); // Spawns a Random Enemy at a Random SpawnSpot
    
    } 
}

The Error I get is:

/Scripts/ZombieSpawn.cs(45,31): error CS1503: Argument `#1' cannot convert `UnityEngine.GameObject' expression to type `string'

The error is appearing because “Zombie[enemyIndex]” is a Game object. And im guessing it needs to be a string.

and With how I have THIS particular script where I cannot just use the prefab name for a string.
because it grabs a random enemy prefab from the enemyIndex line above the instantiate line.

There must be some type of work around here, unfortunatly I have not learned this yet…

Any help is appreciated once again. thanks

bump. Anyone?

I guess I could just make a seperate script for each enemy prefab, but would like to learn the proper way…

If the list contains Prefabs, you can use each item’s .name. It should be the same as the prefab itself and it’s a string.

Thanks for the reply, I will try this out right away

@tobiass
I got it to work with “Zombie[enemyIndex].name” but the enemys are still not syncing?
Im trying to get the enemys position / animation to be the same for all players…

I have a few different scripts for the enemy but Im not sure which one I need to use accross the network:
ZombieSpawn – The script above to spawn the enemys
ZombieSpawnTrigger – activates “ZombieSpawn” script when player is in range(already activates/deactivates for all players)
NetworkEnemy – pretty much just the OnPhotonSerializeView function with position,rotation,animation

They seem to only spawn with group 0, even though the PhotonView is 4