void Update()
    {
        if (spline != null)
        {
            spline.Update(controlPoints);
            spline.Update(resolution);
            spline.DrawSpline(Color.white);

            if (drawNormal)
            {
                spline.DrawNormals(normalExtrusion, Color.red);
            }

            if (drawTangent)
            {
                spline.DrawTangents(tangentExtrusion, Color.cyan);
            }
        }
        else
        {
            spline = new CatmullRom(controlPoints, resolution);
        }


        if (globalTime <= 1)
        {
            globalTime += Time.deltaTime * UpdateProgress();
        }
        else
        {
            globalTime = .001f;
        }

        UpdatePosition(globalTime);
    }
Beispiel #2
0
    void Update()
    {
        if (spline != null)
        {
            spline.Update(controlPoints);
            spline.Update(resolution);
            spline.DrawSpline(Color.white);

            if (drawNormal)
            {
                spline.DrawNormals(normalExtrusion, Color.red);
            }

            if (drawTangent)
            {
                spline.DrawTangents(tangentExtrusion, Color.cyan);
            }
        }
        else
        {
            spline = new CatmullRom(controlPoints, resolution);
        }


        if (speed > 0)
        {
            Debug.Log(spline.GetPoints().Length);

            float distance = Vector3.Distance(spline.GetPoints()[currentWaypointID].position, transform.position);
            transform.position = Vector3.MoveTowards(transform.position, spline.GetPoints()[currentWaypointID].position, Time.deltaTime * speed);

            var rotation = Quaternion.LookRotation(spline.GetPoints()[currentWaypointID].position - transform.position);
            transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * rotationSpeed);

            if (distance <= reachDistance)
            {
                currentWaypointID++;
            }
        }

        if (currentWaypointID >= spline.GetPoints().Length)
        {
            currentWaypointID  = 0;
            transform.position = spline.GetPoints()[currentWaypointID].position;
            transform.rotation = Quaternion.LookRotation(spline.GetPoints()[currentWaypointID].position - transform.position);
        }
    }
Beispiel #3
0
    void Update()
    {
        if (spline != null)
        {
            spline.Update(controlPoints);
            spline.Update(resolution);
            UpdateLinePoints();

            //spline.DrawSpline(Color.white);

            lineRenderer.positionCount = linePoints.Length;
            lineRenderer.SetPositions(linePoints);

            if (drawNormal)
            {
                spline.DrawNormals(normalExtrusion, Color.red);
            }

            if (drawTangent)
            {
                spline.DrawTangents(tangentExtrusion, Color.cyan);
            }
        }
        else
        {
            spline = new CatmullRom(controlPoints, resolution);
        }



        if (progress < 1)
        {
            progress += Time.deltaTime * GetTimeScale();
        }
        else
        {
            progress = .01f;
        }

        UpdatePosition(progress);
    }
Beispiel #4
0
    void Update()
    {
        if (spline != null)
        {
            spline.Update(controlPoints);
            spline.Update(resolution);
            spline.DrawSpline(Color.white);

            if (drawNormal)
            {
                spline.DrawNormals(normalExtrusion, Color.red);
            }

            if (drawTangent)
            {
                spline.DrawTangents(tangentExtrusion, Color.cyan);
            }
        }
        else
        {
            spline = new CatmullRom(controlPoints, resolution);
        }



        if (progress <= 1)
        {
            progress += Time.deltaTime * UpdateProgress();
            //if (!trail.emitting) {
            //trail.Clear();
            //trail.emitting = true;
            //}
        }
        else
        {
            progress = .001f;
            //trail.emitting = false;
        }

        UpdatePosition(progress);
    }
Beispiel #5
0
    void Update()
    {
        if (spline != null)
        {
            spline.Update(controlPoints);
            spline.Update(resolution, closedLoop);
            spline.DrawSpline(color);

            if (drawNormal)
            {
                spline.DrawNormals(normalExtrusion, Color.red);
            }

            if (drawTangent)
            {
                spline.DrawTangents(tangentExtrusion, Color.cyan);
            }
        }
        else
        {
            spline = new CatmullRom(controlPoints, resolution, closedLoop);
        }
    }