How do I make a FPS Boss?

Hello everybody. I am brand new to programming and am going through the FPS tutorial, but the one thing the tutorial does not teach you is how to make a boss character and how to end the game, once everything is dead you just kinda sit there. Here is the script I was thinking my game over condition should be put into

var hitPoints = 100.0; var deadReplacement : Transform; var dieSound : AudioClip;

function ApplyDamage (damage : float) { // We already have less than 0 hitpoints, maybe we got killed already? if (hitPoints <= 0.0) return;

hitPoints -= damage;
if (hitPoints <= 0.0)


function Detonate () { // Destroy ourselves Destroy(gameObject);

// Play a dying audio clip
if (dieSound)
    AudioSource.PlayClipAtPoint(dieSound, transform.position);

// Replace ourselves with the dead body
if (deadReplacement) {
    var dead : Transform = Instantiate(deadReplacement, transform.position, transform.rotation);

    // Copy position & rotation from the old hierarchy into the dead replacement
    CopyTransformsRecurse(transform, dead);


static function CopyTransformsRecurse (src : Transform, dst : Transform) { dst.position = src.position; dst.rotation = src.rotation;

for (var child : Transform in dst) {
    // Match the transform with the same name
    var curSrc = src.Find(;
    if (curSrc)
        CopyTransformsRecurse(curSrc, child);


I was wondering if that would be the correct spot to put it into and what exactly would i put into it to make the game end? any help on this would be greatly appreciated even a book I could look into to find the answer myself would be great.

Thank you so much for your time


You have a few choices. The simplest is to simply exit the application when you want the game over to happen. You can do this using Application.Quit which you can read about here:

This has no effect in the editor or in a web player though!

The second and third options is to restart the game by reloading your current scene OR load another scene (such as a menu/level select). You can do this by using Application.LoadLevel. See this:

Now to check if the game has ended you'll want to tag all enemies and use the following function:

You just need to use this function and then check the length of the array (in the example in the link you would check if gos.length was 0)