Example #1
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.CompareTag("Player"))
        {
            gameManager.health--;

            soundManager.PlayExplosionSound();
            Instantiate(explosion, transform.position, Quaternion.identity);
            shakeCamera.ScreenShake();

            Destroy(gameObject);
        }

        if (collision.gameObject.CompareTag("Projectile"))
        {
            gameManager.score++;

            soundManager.PlayExplosionSound();
            Instantiate(explosion, transform.position, Quaternion.identity);
            shakeCamera.ScreenShake();

            Destroy(collision.gameObject);
            Destroy(gameObject);
        }
    }