Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (!Spline || !Spline.IsInitialized)
        {
            return;
        }
        // Runtime processing
        if (Application.isPlaying)
        {
            // get the TF of the current distance.
            // Note: It's recommended to use the TF based methods in consecutive calls, as the distance based
            // methods need to convert distance to TF internally each time!
            float tf = Spline.DistanceToTF(mDistance);

            // Move using cached values(slightly faster) or interpolate position now (more exact)
            // Note that we pass mTF and mDir by reference. These values will be changed by the Move methods
            mTransform.position = (FastInterpolation) ?
                                  Spline.MoveByFast(ref tf, ref mDir, Speed * Time.deltaTime, Clamping) :
                                  Spline.MoveBy(ref tf, ref mDir, Speed * Time.deltaTime, Clamping);
            mDistance = Spline.TFToDistance(tf);
            // Rotate the transform to match the spline's orientation
            if (SetOrientation)
            {
                transform.rotation = Spline.GetOrientationFast(tf);
            }
        }
        else  // Editor processing: continuously place the transform to reflect property changes in the editor
        {
            InitPosAndRot();
        }
    }
Ejemplo n.º 2
0
        void Update()
        {
            if (cubes == null || !Spline.IsInitialized)
            {
                return;
            }

            // Move Cubes by a certain distance
            for (int i = 0; i < cubes.Length; i++)
            {
                cubes[i].position = Spline.MoveBy(ref tf[i], ref dir[i], Speed * Time.deltaTime, CurvyClamping.Loop);
                cubes[i].rotation = Spline.GetOrientationFast(tf[i]);
            }
        }
Ejemplo n.º 3
0
    void Update()
    {
        if (!Spline || !Spline.IsInitialized)
        {
            return;
        }
        if (Application.isPlaying && mDistance < 2)
        {
            float tf = Spline.DistanceToTF(mDistance);

            mTransform.position = (FastInterpolation) ?
                                  Spline.MoveByFast(ref tf, ref mDir, Speed * Time.deltaTime, Clamping) :
                                  Spline.MoveBy(ref tf, ref mDir, Speed * Time.deltaTime, Clamping);
            mDistance = Spline.TFToDistance(tf);

            if (SetOrientation)
            {
                transform.rotation = Spline.GetOrientationFast(tf);
            }
        }
    }
Ejemplo n.º 4
0
 // Update is called once per frame
 void Update()
 {
     if (!Spline)
     {
         return;
     }
     // Runtime processing
     if (Application.isPlaying)
     {
         // Move at a constant speed?
         if (MoveByWorldUnits)
         {
             // either used cached values(slightly faster) or interpolate position now (more exact)
             // Note that we pass mTF and mDir by reference. These values will be changed by the Move methods
             mTransform.position = (FastInterpolation) ?
                                   Spline.MoveByFast(ref mTF, ref mDir, Speed * Time.deltaTime, Clamping) : // linear interpolate cached values
                                   Spline.MoveBy(ref mTF, ref mDir, Speed * Time.deltaTime, Clamping);      // interpolate now
         }
         else                                                                                               // Move at constant F
                // either used cached values(slightly faster) or interpolate position now (more exact)
                // Note that we pass mTF and mDir by reference. These values will be changed by the Move methods
         {
             mTransform.position = (FastInterpolation) ?
                                   Spline.MoveFast(ref mTF, ref mDir, Speed * Time.deltaTime, Clamping) : // linear interpolate cached values
                                   Spline.Move(ref mTF, ref mDir, Speed * Time.deltaTime, Clamping);      // interpolate now
         }
         // Rotate the transform to match the spline's orientation
         if (SetOrientation)
         {
             transform.rotation = Spline.GetOrientationFast(mTF);
         }
     }
     else // Editor processing: continuously place the transform to reflect property changes in the editor
     {
         InitPosAndRot();
     }
 }