Respawn Alien Zombies

OK I'm using a setup very similar to the FPS tutorial where my enemies, in this case "Alien Zombies" start off at "Way Points" but when I kill them they are dead.

How can I have them respawn at the same location they started off from say after 40 seconds or so after they have disolved/destroyed?

Thomas: Do you mean that I add this to my Alien Zombie's dead replacement?

private var dieTime = Time.time; //When it dies
private var deadTime = 40.0f; //Time dead

function Update () {
    if (Time.time > (dieTime + deadTime))
    {
        Instantiate(alienZombiePrefab, transform.position, Quaternion.identity);
    }
}

If I'm following you corectly I get this error: Assets/WeaponScripts/ZombieAlienRespawn.js(7,29): BCE0005: Unknown identifier: 'alienZombiePrefab'.

2 Answers

2

At the start of the robot script run this

var robotPrefab : Transform; // Put the alive robot prefab here

When they die run this script in the dead body.

private var dieTime = Time.time; // When it dies private var deadTime = 40.0f; //Time dead function Update () {

if (Time.time > (dieTime + deadTime))
{
    Instantiate(robotPrefab, transform.position, Quaternion.identity);

}

Hope it helps :D

}

Thanks Thomas, I edited my question with my result so I think I'm doing it wrong or miss reading something?

–

ohh yeah, i forgot at the start of the script put this line,

var alienZombiePrefab : Transform;

Add this script to your dead robot prefab and in the inspector window you add the alive zombie prefab where it says alienZombiePrefab, hope it helps :D. PS If you wanna work together post it here :D, luck.

What I ended up doing was just making a cuple of empty game objects and placed them in what I figured would be good spawn positions and then just had those spawn a new zombie alien every 200 seconds. That way hopefully my player will have time to run around and explore the level, still have lots of zombies to shoot but hopefully not get over run with them ;) I'm looking for work myself actually :(

–