public void SetDesination()
    {
        if (patroling)
        {
            if (wayPointsVisited > 0)
            {
                wayPointConnect newWayPoint = currentWayPoint.NextWayPoint(previousWayPoint);
                previousWayPoint = currentWayPoint;
                currentWayPoint  = newWayPoint;
            }

            Vector3 targetVector = currentWayPoint.transform.position;
            navMeshAgent.SetDestination(targetVector);
            isTravelling = true;
        }

        else if (isApproaching)
        {
            transform.LookAt(player.transform);
            navMeshAgent.isStopped = true;
            navMeshAgent.SetDestination(player.transform.position);
            navMeshAgent.isStopped = false;
        }

        else if (isAttacking)
        {
            navMeshAgent.isStopped = true;
        }

        else
        {
            Debug.Log("NOT SURE WHERE I'M GOING");
        }
    }
Esempio n. 2
0
    private void SetDesination()
    {
        if (patroling)
        {
            if (wayPointsVisited > 0)
            {
                wayPointConnect newWayPoint = currentWayPoint.NextWayPoint(previousWayPoint);
                previousWayPoint = currentWayPoint;
                currentWayPoint  = newWayPoint;
            }

            Vector3 targetVector = currentWayPoint.transform.position;
            navMeshAgent.SetDestination(targetVector);
            isTravelling = true;
        }
    }