Пример #1
0
    void OnCollisionEnter(Collision col)
    {
        if (col.gameObject.layer == 8)
        {
            Destroy(gameObject, 4);
        }
        if (owner.Equals(col.gameObject))
        {
            return;
        }

        var hit    = col.gameObject;
        var health = hit.GetComponent <Health>();

        if (health != null)
        {
            health.TakeDamage(damage);
            if (health.currentHealth <= 0 && player != null)
            {
                player.AddScore(10);
            }
        }
    }