コード例 #1
0
    private IEnumerator SetTarget()
    {
        Debug.Log("starting SetTarget");
        Debug.Log(Tour.pathways);
        rb.transform.position = new Vector3(Tour.pathways[0].GetPoints()[0].x, Tour.pathways[0].GetPoints()[0].y, Tour.pathways[0].GetPoints()[0].z);

        for (int p = 0; p < Tour.pathways.Count; p++)
        {
            currentPath = Tour.pathways[p];
            Debug.Log("in tour, going to next path:   " + currentPath.GetName() + "   :   " + p);
            for (int i = 0; i < currentPath.GetPointsLength() - 1; i++)
            {
                startPos = new Vector3(currentPath.GetPoints()[i].x, currentPath.GetPoints()[i].y, currentPath.GetPoints()[i].z);
                target   = new Vector3(currentPath.GetPoints()[i + 1].x, currentPath.GetPoints()[i + 1].y, currentPath.GetPoints()[i + 1].z);

                yield return(new WaitForSeconds(lerpTime));

                Debug.Log("going to next point: " + (i + 1));
            }
            startPos = currentPath.GetPoints()[currentPath.GetPointsLength() - 1];
            target   = currentPath.GetPoints()[currentPath.GetPointsLength() - 1];
            yield return(new WaitForSeconds(lerpTime));
        }


        StartCoroutine("SetTarget");
    }