Example #1
0
 private void FollowPlayer()
 {
     if (IsPlayerTooFarToFollow() || IsRouteCenterTooFar())
     {
         SetAiDestination(_currentTarget);
         _state = PatrolEnemyStates.BackToRoute;
     }
 }
Example #2
0
 private void Patrol()
 {
     if (IsPlayerClose())
     {
         SetAiDestination(_player.transform);
         _state = PatrolEnemyStates.FollowingPlayer;
         _aiPath.endReachedDistance   = _endReachedDistance;
         _aiPath.pickNextWaypointDist = _pickNextWaypointDistance;
         _aiPath.maxSpeed             = _maxSpeed;
     }
 }
Example #3
0
    private void FixedUpdate()
    {
        State = SetState();

        switch (State)
        {
        case PatrolEnemyStates.Patrol:
            Patrol();
            break;

        case PatrolEnemyStates.Chase:
            timer = maxtime;
            Chase();
            break;
        }
    }
Example #4
0
        private void TargetReached()
        {
            Debug.Log("Target reached");
            if (_state == PatrolEnemyStates.Patrolling)
            {
                SelectNextRoutePoint();
            }

            if (_state == PatrolEnemyStates.BackToRoute)
            {
                _aiPath.endReachedDistance   = 0.1f;
                _aiPath.pickNextWaypointDist = 0.1f;
                _aiPath.maxSpeed             = 0.5f;

                _state = PatrolEnemyStates.Patrolling;
            }
        }