コード例 #1
0
    public IEnumerator FollowPath()
    {
        IsStopped = false;
        while (path.Count > 0 && !isStopped)
        {
            float distanceToNextNode = Vector3.Distance(owner.Rigidbody.position, path[0]);
            float distanceToLast     = Vector3.Distance(owner.Rigidbody.position, path[path.Count - 1]);

            if (distanceToNextNode < 0.4f || distanceToLast < stopDistance)
            {
                path.Remove(path[0]);
            }
            else
            {
                owner.MoveTo(path[0]);
            }

            yield return(null);
        }
        IsStopped = true;
    }