I have a class, where my enemies spawn at the start of the game. When my player dies, I wanna call the spawn class again to let the enemies spawn again. But when I do so, nothing is happening.
public class EnemySpawn : MonoBehaviour
{
public GameObject [] Enemies;
public GameObject [] SpawnClone;
public Transform [] locations;
public void Start()
{
SpawnClone[0] = Instantiate(Enemies[0], locations[0].transform.position, Quaternion.Euler(0,0,0)) as GameObject;
SpawnClone[1] = Instantiate(Enemies[1], locations[1].transform.position, Quaternion.Euler(0,0,0)) as GameObject;
SpawnClone[2] = Instantiate(Enemies[2], locations[2].transform.position, Quaternion.Euler(0,0,0)) as GameObject;
}
}
//other class where I wanna call the Start method again to spawn enemies everytime I die
private EnemySpawn enemyspawn;
private void Die()
{
m_character.NotifyDied();
if (m_canRespawn)
{
SetVulnerable();
RemovePoison();
m_hazards.Clear();
gameObject.transform.position = m_spawnPosition;
SetHealth(m_maxHealth);
enemyspawn.Start();
}
else {
Destroy(gameObject);
}
}