Example #1
0
 public Vector3 CalcPos(float t)
 {
     return(new Vector3(
                curveX.Calc(t).position,
                curveY.Calc(t).position,
                curveZ.Calc(t).position
                ));
 }
Example #2
0
    IEnumerator Move(CatmullRomCurve curveX, CatmullRomCurve curveY)
    {
        float time = 0;

        transform.position = new Vector3(curveX.Calc(0).position, curveY.Calc(0).position, 0);
        transform.rotation = Quaternion.LookRotation(
            new Vector3(curveX.Calc(0).velocity, curveY.Calc(0).velocity, 0)
            );
        yield return(null);

        while ((time += Time.deltaTime) <= 10)
        {
            transform.position = new Vector3(curveX.Calc(time / 10).position, curveY.Calc(time / 10).position, 0);
            transform.rotation = Quaternion.LookRotation(
                new Vector3(curveX.Calc(time / 10).velocity, curveY.Calc(time / 10).velocity, 0)
                );
            yield return(null);
        }
    }