Пример #1
0
    public void Attack(Home home)
    {
        SetSteering((home.transform.position - transform.position).normalized);
        motor.SteerAt(home.transform);
        Debug.Log($"Minion, Attack : {gameObject.name} attack {home.gameObject.name}");
        var distance = Vector3.Distance(transform.position, home.transform.position);

        if (distance <= 4f && home.GetHealth() > 0)
        {
            animator.SetBool("isAttacking", true);
            attack = true;
            Debug.Log($"Minion, Attack : {gameObject.name} hit {home.gameObject.name}");
            home.RemoveHealth(damage);
            if (!home.RemoveHealth(damage))
            {
                team.AddKill();
            }
        }
        else
        {
            attack = false;
            animator.SetBool("isAttacking", false);
        }
    }