Exemple #1
0
    private void aggressiveBehavior()
    {
        float distance = Vector3.Distance(transform.position, PlayerManager.instance.playerObject.transform.position);

        if (distance > creatureAI.creature.triggerRange)
        {
            isChasing = false;
        }
        else
        {
            isChasing = true;
        }

        if (distance <= creatureAI.creature.creatureAttackRange && isChasing)
        {
            creatureAI.creatureAttack();
        }

        if (isChasing)
        {
            StopCoroutine(creatureMotor.getCreatureAI().creatureWander());
            creatureMotor.getCreatureAI().getCreatureAgent().SetDestination(PlayerManager.instance.playerObject.transform.position);
            transform.LookAt(PlayerManager.instance.playerObject.transform.position);
        }
        else if (!isChasing)
        {
            creatureMotor.startWander();
            return;
        }
    }