help with end game after targets are .....

hi guys i need a helping hand in my game i am trying to work out a way of ending my game once all the targets are destroyed but everything i try i just can’t get my head around can someone set me on the right path please

ok for more detail i have 5 targets that get shot once they are shot they are destoryed i need to write a script so that everytime a target is destroyed (tag “target”) it is counted once all 5 are destroyed to make it change to a end game screen showing the remaining time as a score


Here is what you can do
Step 1.
Add the following script to your target

var Counter:GameObject;
var life:float = 20;//anything can go here
function Update (){
//you need to decrease the life by using  sendmessage from your gun
if(life <=5){

Step 2.Create an empty gameobject name it anything you like
(eg.AI) assign the AI to the Conuter in the script

Add these to your
AI object

`var ttltar:float = 5;//no of targets.

function Getcount () {

function Update(){
if(ttltar <=0){
//your Game finish code


Create an empty gameobject withname TargetHead and tag it as TargetHead and make the Target objects as child of thid object

Hers is your TargetHead Script

var targethead:GameObject;

function Update(){

 var Targetcount:Array =

if(Targetcount.Length < 1){
//gameover script

We need more information than what you have provided. I will gladly help you if I can figure out exactly what issue you are having. If you want to check that no game objects of X exists ( essentially, all dead ), you can use the following.

var mobcount : float ;
var respawns = GameObject.FindGameObjectsWithTag ("Respawn");
for (var respawn in respawns)
    mobcount += 1;

if ( !mobcount )

I don’t recommend putting this in Update. Instead, create another function.