Game Development Reference
In-Depth Information
function Start () {
Score=0;
HiScore=1000;
}
function Update () {
}
3. Attach this file to the GameMaster game object to have the Score and HiS-
core variables displayed on screen. Since we don't have a two player fea-
ture, we will keep the PL2 score as a mere string placeholder. You can add
such feature as an exercise, if you want to.
4. The next step is to have the score increase as the player destroys enemy
aliens. We can do that inside the ControlPLBullet script.
5. Open it in MonoDevelop , get to the OnTriggerEnter() function and add
the following line:
//add 50 points to score for each alien
destroyed
DisplayScore.Score+=50;
6. For the sake of clarity here is the updated OnTriggerEnter() function of
the ControlPLBullet script:
//this function checks for collisions
function OnTriggerEnter(other:Collider)
{
//if bullets collides with aliens,
destroy both
if(other.gameObject.tag=="Enemies"){
Destroy(gameObject);
Destroy(other.gameObject);
//add 50 points to score for
Search WWH ::




Custom Search