// Update is called once per frame void Update() { if (health <= 0) { if (playerHealth) { playerHealth.AddScore(score); } Destroy(gameObject); } }
void OnTriggerEnter(Collider other) { if (other.tag == "Bullet") { Instantiate(explosion1, transform.position, transform.rotation); Instantiate(explosion2, transform.position, transform.rotation); //Instantiate (explosion); //explosion.transform.position = t.position; print("after" + t.position); print("Collision"); Destroy(gameObject); Destroy(other.gameObject); gameController.AddScore(); } }
// Update is called once per frame void Update() { if (health <= 0) { playerHealth.AddScore(score); if (enemy_prefab) { for (int i = 0; i < num_enemies_spawned_on_death; i++) { float rand_x = Random.Range(-5.0f, 5.0f); float rand_z = Random.Range(-5.0f, 5.0f); Vector3 pos = new Vector3(transform.position.x + rand_x, transform.position.y, transform.position.z + rand_z); Instantiate(enemy_prefab, pos, Quaternion.identity); } } Destroy(gameObject); } }
void OnTriggerEnter(Collider other) { if (other.tag == "Player") { Instantiate(explosion, transform.position, transform.rotation); //Instantiate (explosion); //explosion.transform.position = t.position; print("after" + t.position); print("Collision"); Destroy(gameObject); //Destroy (other.gameObject); gameController.AddScore(); gameController.GateFall(); } else { return; } }
void Attack() { playerHealth.TakeDamage(attackDamage); playerHealth.AddScore(enemyHealth.score); Destroy(gameObject); }