コード例 #1
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 (globalTime <= 1)
        {
            globalTime += Time.deltaTime * UpdateProgress();
        }
        else
        {
            globalTime = .001f;
        }

        UpdatePosition(globalTime);
    }
コード例 #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);
        }
    }
コード例 #3
0
ファイル: SplineMover.cs プロジェクト: stormsen74/EHAnim
    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);
    }
コード例 #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);
    }
コード例 #5
0
ファイル: Spline.cs プロジェクト: UnManuel/Cars
    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);
        }
    }