charlenedelceppo / Assignment-2-space-invaders

This is a space invaders game which was created by Unity. The game consists of a spaceship (player) which needs to kill the aliens by shooting the laser upwards to hit them. The aliens will be moving across the screen from left to right and right to left. The player can move the spaceship across the screen too. The aliens will be shooting lasers too and if they hit the spaceship the player's health will start to decrease. The health will be set to 100 and if they hit th player enough to 0 the game ends "game over". When starting the game the user will entering the name and will be shown during the gameplay.
0 stars 0 forks source link

When Spaceship is hitting the alien with laser slot the score is not increasing. #2

Open charlenedelceppo opened 11 years ago

charlenedelceppo commented 11 years ago

The mistake I was doing is that I didn't make the code in the alien controller OnTriggerEnter score ++ , so that when the laserslot hit the alien the score will increase.

charlenedelceppo commented 11 years ago

//function when laser hit the alien function OnTriggerEnter(other:Collider) { if(other.gameObject.tag=="laserSlot") { var parent = transform.parent;

    //increasing the score and hit when laser hit the alien
    SpaceshipController.score++;

    //destroy the laser
    Destroy(this.gameObject);

}

}