Exemplo n.º 1
0
        /// <summary>
        /// Returns a position on the spline at the given percentage.
        /// </summary>
        public Vector3 GetPosition(float percentage, bool evenDistribution = true, int distributionSteps = 100)
        {
            //evaluate curve:
            CurveDetail curveDetail = GetCurve(percentage);

            //avoid an error in editor usage where this index can be -1:
            if (curveDetail.currentCurve < 0)
            {
                return(Vector3.zero);
            }

            SplineAnchor startAnchor = Anchors[curveDetail.currentCurve];
            SplineAnchor endAnchor   = Anchors[curveDetail.currentCurve + 1];

            return(BezierCurves.GetPoint(startAnchor.Anchor.position, endAnchor.Anchor.position, startAnchor.OutTangent.position, endAnchor.InTangent.position, curveDetail.currentCurvePercentage, evenDistribution, distributionSteps));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns a facing vector at the given percentage along the spline to allow content to properly orient along the spline.
        /// </summary>
        public Vector3 GetDirection(float percentage)
        {
            //get direction:
            CurveDetail curveDetail = GetCurve(percentage);

            //avoid an error in editor usage where this index can be -1:
            if (curveDetail.currentCurve < 0)
            {
                return(Vector3.zero);
            }

            SplineAnchor startAnchor = Anchors[curveDetail.currentCurve];
            SplineAnchor endAnchor   = Anchors[curveDetail.currentCurve + 1];

            return(BezierCurves.GetFirstDerivative(startAnchor.Anchor.position, endAnchor.Anchor.position, startAnchor.OutTangent.position, endAnchor.InTangent.position, curveDetail.currentCurvePercentage).normalized);
        }