void OnTriggerEnter(Collider other) { if (other.tag == "Player") { SpaceshipController spaceship = other.GetComponent <SpaceshipController>(); if (spaceship != null) { spaceship.ChangeHealth(-1); } Instantiate(playerExplosion, other.transform.position, other.transform.rotation); } else { Destroy(other.gameObject); } if (hit < n_hit) { hit++; } else { Instantiate(explosion, transform.position, transform.rotation); var obj = Instantiate(floatingText, scorePosition.position, Quaternion.identity); GameController.Instance.AddScore(scoreValue); obj.GetComponent <FloatingText>().value = scoreValue; Destroy(gameObject); GameObject[] enermies = GameObject.FindGameObjectsWithTag("Enemy"); source.PlayOneShot(audioClip); foreach (GameObject enermy in enermies) { Destroy(enermy); } GameController.Instance.DiplayWinningScreen(); } }
void OnTriggerEnter(Collider collider) { if (collider.tag == "Player") { SpaceshipController spaceship = collider.GetComponent <SpaceshipController>(); if (spaceship != null) { spaceship.ChangeHealth(1); Destroy(gameObject); } } }
void OnTriggerEnter(Collider other) { //Instantiate(explosion, transform.position, transform.rotation); if (other.tag == "Player") { Debug.Log("atk"); SpaceshipController spaceship = other.GetComponent <SpaceshipController>(); if (spaceship != null) { spaceship.ChangeHealth(-1); } Instantiate(playerExplosion, other.transform.position, other.transform.rotation); } else { Destroy(other.gameObject); } Destroy(gameObject); }
void OnTriggerEnter(Collider other) { Instantiate(explosion, transform.position, transform.rotation); if (other.tag == "Player") { SpaceshipController spaceship = other.GetComponent <SpaceshipController>(); if (spaceship != null) { spaceship.ChangeHealth(-1); } Instantiate(playerExplosion, other.transform.position, other.transform.rotation); } else { Destroy(other.gameObject); } var obj = Instantiate(floatingText, scorePosition.position, Quaternion.identity); GameController.Instance.AddScore(scoreValue); obj.GetComponent <FloatingText>().value = scoreValue; Destroy(gameObject); }