Пример #1
0
    private void OnTriggerEnter2D(Collider2D hitInfo)
    {
        EnemyCrab enemy = hitInfo.GetComponent <EnemyCrab>();

        if (enemy != null)
        {
            enemy.TakeDamage(damage);
        }
        Instantiate(impactEffect, transform.position, transform.rotation);
        Destroy(gameObject);
    }
Пример #2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Pickup"))
        {
            return;
        }

        EnemyCrab enemy = collision.GetComponent <EnemyCrab>();

        if (enemy)
        {
            enemy.TakeDamage(25);
        }

        if (impactEffect)
        {
            Instantiate(impactEffect, transform.position, transform.rotation);
        }

        Destroy(gameObject);
    }