Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Mar 10th, 2012  |  syntax: None  |  size: 0.81 KB  |  views: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. private var spawnTime : float;
  2. var godDelay : float;
  3. var explosion : GameObject;
  4. var explosionSound : GameObject;
  5.  
  6. function Awake () {
  7.         spawnTime = Time.time;
  8. }
  9.  
  10. function OnTriggerEnter (col : Collider) {
  11.         if (( (col.gameObject.tag == "EnemyProjectile") || (col.gameObject.tag == "Enemy")) && (Time.time > spawnTime + godDelay)) {
  12.                         Instantiate(explosion, transform.position, transform.rotation);
  13.                         Instantiate(explosionSound, transform.position, transform.rotation);
  14.                         GameController.lives -= 1;
  15.                         if (GameController.lives > 0) {
  16.                                 gameObject.Find("GameController").GetComponent(GameController).Respawn();
  17.                         } else {
  18.                                 GameController.gameOver = true;
  19.                         }
  20.                         if (col.gameObject.tag == "Enemy") {
  21.                                 GameController.totalEnemies -= 1;
  22.                         }
  23.                         Destroy(col.gameObject);
  24.                         Destroy(gameObject);
  25.         }
  26. }
clone this paste RAW Paste Data