Beispiel #1
0
    public void TakeDamage(int damage)
    {
        health -= damage;

        if (health <= 0)
        {
            ItemPickup itemPickup = GetComponent <ItemPickup>();
            if (itemPickup != null)
            {
                if (itemPickup.item != null)
                {
                    StartCoroutine(itemPickup.ThrowItem());
                }
            }

            Instantiate(deathEffect, transform.position, Quaternion.identity);
            Destroy(gameObject);
        }
    }