Exemple #1
0
    private void OnTriggerEnter2D(Collider2D col)
    {
        //Destroy(col.gameObject);
        BulletScript bullet = col.gameObject.GetComponent <BulletScript>();

        bullet.Hit();
    }
Exemple #2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        BulletScript bullet = collision.gameObject.GetComponent <BulletScript>();

        targetHealth -= bullet.GetDamage();
        if (targetHealth <= 0)
        {
            Destroy(gameObject);
        }
        bullet.Hit();
    }