Score through hiting targets and time based score.

Hi guys I know there are a lot of questions about how to make a scoring system but this is going to be a little different because I need something else then what has already been answered.

What I need is a score system that when I have destroyed one of my targets I get points for doing so the way I destroy targets is by using a gun and shooting bullets at targets to destroy them. There are 2 types of targets one set of targets gives you 10 points and the other targets that are optional gives you 50 points I also need to be able to give points based on time so lets say depending on how many seconds are left give the player an extra 10 points per second; I would also like a system that takes points if you miss a target so lets say minus 10 points every time you miss. Basically I’m creating an FPS where the score is based of targets hit and time. Tbh I need this for my uni assignment and I’m just a little stumped and any help would be really useful so yeah please help. btw I have made a start on the code now I just need your help to finish it :).

// textfield to hold the score and score variable
private var textfield:GUIText;
private var score:int;

function Awake(){

	textfield = GameObject.Find("GUI/ScoreCount").GetComponent(GUIText);

	score = 0;
	UpdateScoreText();
}
function UpdateScoreText(){

	// update textfield with score
	textfield.text = score.ToString();
}

so yeah please help becauase I’m so close to getting this finished and I just need a bit of help to finish this project of :).

private var score:int;

function OnCollisionEnter(other : Collision )
    {
    switch(other.transform.tag)
    {
    case "10points": score+=10; Destroy(other.gameobject);
                             break;
    case "optinal50": score+=50; Destroy(other.gameobject);
                             break;
    default: score-=10;
                          break;

}
}

//call at the end of game
function EndGame()
{
var bonus = timeRemaining * 10;
score = score+bonus;
}

ok… when your bullet hit any other objects other than your targets the switch will go to default, you will know that you have skipped your target and the score gets deducted. tag your normal target “10points”, optional targets “optional50”, you have call the EndGame() at gameover so the remaining points gets added to score… the code is in js now… i have not tested it though. :slight_smile: