Exemple #1
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        projectile bullet = collider.gameObject.GetComponent <projectile> ();

        if (bullet)
        {
            hp -= bullet.GetDmg();
            bullet.Hit();
            if (hp <= 0)
            {
                Destroy(gameObject);
                keeper.Score(score);
                AudioSource.PlayClipAtPoint(deathSound, transform.position);
            }
        }
    }
Exemple #2
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        projectile bullet = collider.gameObject.GetComponent <projectile> ();

        if (bullet)
        {
            hp -= bullet.GetDmg();
            bullet.Hit();
            if (hp <= 0)
            {
                AudioSource.PlayClipAtPoint(deathSound, transform.position);
                sr        = GetComponent <SpriteRenderer> ();
                sr.sprite = destroyedPlayer;
                dead      = true;
                //Destroy (gameObject);
            }
        }
    }