am spawning an object at some random time interval. am using co-routines for that. it shows a error message which i couldn’t understand. can some one help me what is the error about. thanks in advance.
using UnityEngine;
using System.Collections;
public class enemySpawner_5 : MonoBehaviour {
public GameObject[] enemies_5;
bool isSpawning = false;
public int minTime = 2;
public int maxTime = 4;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
//We only want to spawn one at a time, so make sure we're not already making that call
if(!isSpawning)
{
//making a condition that we can spawn
isSpawning = true;
int enemyIndex = Random.Range(0, enemies_5.Length);
StartCoroutine(spawnObject(enemyIndex, Random.Range(minTime, maxTime)));
}
}
IEnumerator spawnObject( int index, int seconds)
{
//instantiating position
Vector3 position = new Vector3(-1.355466f, 7f, -0.5f);
//instantiating the object
Instantiate(enemies_5[index], position, transform.rotation);
//we have spawned so we could start another spawn
isSpawning = false;
}
}