Exemplo n.º 1
0
    void Update()
    {
        t += Time.deltaTime / (Curve.Length / Speed);

        if(t > 1)
        {
            Curve = Curve.NextSegment()[0];
            t -= 1;
        }

        transform.position = Curve.GetPoint(t);

        transform.forward = Curve.GetTangent(t);
    }
Exemplo n.º 2
0
    public static void DrawHandles(BezierSystemSegment seg, Color color)
    {
        if (seg == null)
            return;

        for (int i = 0; i < seg.Resolution; i++)
        {
            float t = (float)i / (float)seg.Resolution;
            float t1 = (float)(i + 1) / (float)seg.Resolution;

            var old = Handles.color;
            Handles.color = color;
            Handles.DrawLine(seg.GetPoint(t), seg.GetPoint(t1));
            Handles.color = old;
        }
    }