void OnTriggerEnter2D(Collider2D collider) { // Get The laser object GameObject laser = collider.gameObject; // Get the projectile Projectile projectile = laser.GetComponent <Projectile> (); // If not a projectile, return if (!projectile) { return; } // Remove Health health -= projectile.Dammage; // Destroy laser projectile.Hit(); // Check the remining health if (health <= 0) { ScoreKeeper.AddPoints(scoreValue); GameObject.Destroy(gameObject); } }
void OnTriggerEnter(Collider coll) { PointsPickup pu = coll.GetComponent <PointsPickup> (); if (pu != null) { GameObject.Destroy(pu.gameObject); _pointsHUD.AddPoints(pu.points); } }
private void OnTriggerEnter2D(Collider2D collision) { Projectile missle = collision.gameObject.GetComponent <Projectile>(); if (missle) { health -= missle.GetDamage(); missle.Hit(); if (health <= 0) { Destroy(gameObject); scoreKeeper.AddPoints(pointePerEnemy); AudioSource.PlayClipAtPoint(enemyDies, transform.position); } } }
void OnTriggerEnter2D(Collider2D collision) { Projectile missile = collision.gameObject.GetComponent <Projectile>(); if (missile) { AudioSource.PlayClipAtPoint(hit, transform.position); Instantiate(smallExplosion, transform.position, Quaternion.identity); missile.Hit(); health -= missile.GetDamage(); if (health <= 0) { Destroy(gameObject); //highScore.AddPoints(); ScoreKeeper.AddPoints(scoreValue); AudioSource.PlayClipAtPoint(die, transform.position); Instantiate(bigExplosion, transform.position, Quaternion.identity); } //Debug.Log("Hit by projectile"); } }