public void TakeDamage(float damage) { health -= damage; if (health <= 0f) { animator.SetTrigger("Killed"); if (alive) { inventoryController.AddPoints(pointsOnDeath); inventoryController.AddKill(); gameController.LowerZombieCount(); } alive = false; characterController.enabled = false; agent.isStopped = true; if (Random.Range(0, 100) < 25) { Vector3 newPosition = transform.position + new Vector3(0f, 1f, 0f); Instantiate(powerUps[Random.Range(0, powerUps.Length)], newPosition, Quaternion.identity); } Invoke("Die", 5.0f); } }