Exemplo n.º 1
0
    IEnumerator Start()
    {
        while (true)
        {
            yield return(new WaitForSeconds(0.5f));

            if (transform.childCount > 0)
            {
                if (points == null || points.Length != transform.childCount)
                {
                    points = new Vector3[transform.childCount];
                }
                for (int i = 0; i < transform.childCount; i++)
                {
                    points[i] = transform.GetChild(i).transform.position;
                }

                for (int i = 0; i < pointCount; i++)
                {
                    var     t     = (i + 0f) / (pointCount - 1);
                    Vector3 point = BSpline.GetBStylePoint(points[0], points[1], points[2], t);
                    lineRender.SetPosition(i, point);
                }
            }
        }
    }