Example #1
0
        private void PatrolBehaviour()
        {
            Vector3 pos = Vector3.zero;

            _mover.SetSpeed(_patrolSpeed);

            if (_path != null)
            {
                if (AtWaypoint())
                {
                    _timeSinceLastPatrolled = 0;
                    _pathIndex = _path.GetJ(_pathIndex);
                }

                if (_timeSinceLastPatrolled - _dwellingTime >= Mathf.Epsilon)
                {
                    pos = _path.GetWaypoint(_pathIndex);
                }
            }
            else
            {
                pos = _guardLocation.value;
            }

            _mover.MoveToLocation(pos);
        }