示例#1
0
    void doUpdate()
    {
        if (!Spline || !Spline.IsInitialized)
        {
            return;
        }
        // Runtime processing
        if (Application.isPlaying)
        {
            int dir = Dir;
            // 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.MoveByConnectionFast(ref Spline, ref mTF, ref dir, Speed * Time.deltaTime, Clamping, MinTagMatches, buildTags()) : // linear interpolate cached values
                                      Spline.MoveByConnection(ref Spline, ref mTF, ref dir, Speed * Time.deltaTime, Clamping, MinTagMatches, buildTags());      // interpolate now
            }
            else                                                                                                                                                // Move at constant F
                   // either used cached values(slightly faster) or interpolate position now (more exact)
                   // Note that we pass Spline, mTF and mDir by reference. These values will be changed by the MoveConnection methods
            {
                mTransform.position = (FastInterpolation) ?
                                      Spline.MoveConnectionFast(ref Spline, ref mTF, ref dir, Speed * Time.deltaTime, Clamping, MinTagMatches, buildTags()): // interpolate now
                                      Spline.MoveConnection(ref Spline, ref mTF, ref dir, Speed * Time.deltaTime, Clamping, MinTagMatches, buildTags());     // interpolate now
            }
            // Rotate the transform to match the spline's orientation
            if (SetOrientation)
            {
                transform.rotation = Spline.GetOrientationFast(mTF);
            }

            Dir = dir;
        }
        else // Editor processing: continuously place the transform to reflect property changes in the editor
        {
            InitPosAndRot();
        }
    }