コード例 #1
0
    //The patrolling job. The BotNavigation class is used to manage the movement of the guard from waypoint to waypoint.
    //Note that the BotNavigation class has a nice visual editor, make sure you take a look!
    IEnumerator Patrolling()
    {
        while (true)
        {
            guard.speed = patrolSpeed;

            guard.SetDestination(botNav.CurrentPosition());

            while (!WithinRange(_transform.position, guard.destination))
            {
                guard_motor.facingDirection = botNav.CurrentPosition() - _transform.position;
                yield return(null);
            }

            botNav.NextPosition();

            guard_motor.facingDirection = botNav.CurrentPosition() - _transform.position;

            guard.speed = 0f;

            yield return(new WaitForSeconds(1f));
        }
    }