public Quaternion PathDirection(float t) { int requestedSegment; if (t >= 1f) { t = 1f; requestedSegment = SegmentCount() - 1; } else { t = Mathf.Clamp01(t) * SegmentCount(); requestedSegment = (int)t; t -= requestedSegment; } Vector3[] segmentPoints = LocalSegment(requestedSegment); Vector3 tangent = Bezier.CubicTangent(segmentPoints[0], segmentPoints[1], segmentPoints[2], segmentPoints[3], t); return(Bezier.CubicOrientation(tangent, Vector3.up)); }