I need to use 4/8 different spawning points in 360 degree around the player. Each time something spawns it makes its way to the player and then de-spawns once it hits/or goes past the player or the player hits it.
At the current state of my game I have a spawn manager working and it can spawn to several different locations an array of prefabs. But my script for moving the prefabs toward the player is on the prefabs (Depending on where they are moving they have to move a different direction right?)
So now I am trying to design a system that uses several different spawn managers all working independently of each other and use some sort of bool to say whether they are allowed to spawn…
but i think it might be easier to set up the original cube manager script to have the ability to spawn specific range of prefabs depending on the spawn location which would be random of course.
Here is the script to the cube manager Any help would be amazing!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CubeSpawnManager : MonoBehaviour
{
public GameObject[] Spawnpoints;
public GameObject[] Cubeprefabs;
private int index;
private int indexcube;
public float timeRate;
void Start()
{
StartCoroutine(CreateCubes());
}
private IEnumerator CreateCubes()
{
while (true)
{
index = Random.Range(0, 4);
indexcube = Random.Range(0, 2);
GameObject cube = Instantiate(Cubeprefabs[indexcube], Spawnpoints[index].transform.position, Quaternion.Euler(0, 0, 0)) as GameObject;
cube.transform.SetParent(transform);
yield return new WaitForSeconds(timeRate);
}