Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private var spawnTime : float;
- var godDelay : float;
- var explosion : GameObject;
- var explosionSound : GameObject;
- function Awake () {
- spawnTime = Time.time;
- }
- function OnTriggerEnter (col : Collider) {
- if (( (col.gameObject.tag == "EnemyProjectile") || (col.gameObject.tag == "Enemy")) && (Time.time > spawnTime + godDelay)) {
- Instantiate(explosion, transform.position, transform.rotation);
- Instantiate(explosionSound, transform.position, transform.rotation);
- GameController.lives -= 1;
- if (GameController.lives > 0) {
- gameObject.Find("GameController").GetComponent(GameController).Respawn();
- } else {
- GameController.gameOver = true;
- }
- if (col.gameObject.tag == "Enemy") {
- GameController.totalEnemies -= 1;
- }
- Destroy(col.gameObject);
- Destroy(gameObject);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement