Ejemplo n.º 1
0
        // Use this for initialization
        IEnumerator Start()
        {
            if (Spline && Cube)
            {
                while (!Spline.IsInitialized)
                {
                    yield return(null);
                }

                cubes    = new Transform[Amount];
                tf       = new float[Amount];
                dir      = new int[Amount];
                cubes[0] = Cube;
                tf[0]    = 0;
                dir[0]   = (Speed >= 0) ? 1 : -1;
                // Scale Cube depending on Spline length and number of cubes
                float sc = Spline.Length / Amount;
                Cube.localScale = new Vector3(sc * 0.7f, sc * 0.7f, sc * 0.7f);

                // Create and position cubes
                Cube.position = Spline.InterpolateByDistance(0);
                for (int i = 1; i < Amount; i++)
                {
                    {
                        tf[i]             = Spline.DistanceToTF(i * sc);
                        cubes[i]          = getCube();
                        cubes[i].position = Spline.Interpolate(tf[i]);
                        cubes[i].rotation = Spline.GetOrientationFast(tf[i]);
                        dir[i]            = (Speed >= 0) ? 1 : -1;
                    }
                }

                Speed = Mathf.Abs(Speed);
            }
        }
Ejemplo n.º 2
0
    void Calculate()
    {
        if (selcount == 0)
        {
            return;
        }
        pos = new UnityEngine.Vector3[selcount];
        up  = new UnityEngine.Vector3[selcount];
        tan = new UnityEngine.Vector3[selcount];

        for (int i = 0; i < selcount; i++)
        {
            pos[i] = (UseWorldUnits) ? Spline.InterpolateByDistance(StartOffset + Step * i) : Spline.Interpolate(StartOffset + Step * i);
            up[i]  = (UseWorldUnits) ? Spline.GetOrientationUpFast(Spline.DistanceToTF(StartOffset + Step * i)) : Spline.GetOrientationUpFast(StartOffset + Step * i);
            tan[i] = (UseWorldUnits) ? Spline.GetTangentByDistance(StartOffset + Step * i) : Spline.GetTangent(StartOffset + Step * i);
        }
    }