/// <summary>Get the orientation the curve at a point along the path.</summary> /// <param name="pos">Position along the path. Need not be normalized.</param> /// <returns>World-space orientation of the path, as defined by tangent, up, and roll.</returns> public override Quaternion EvaluateOrientation(float pos) { Quaternion result = transform.rotation; if (Waypoints.Length > 0) { float roll = 0; int indexA, indexB; pos = GetBoundingIndices(pos, out indexA, out indexB); if (indexA == indexB) { roll = Waypoints[indexA].Roll; } else { UpdateControlPoints(); roll = ExtSpline.Bezier1(pos - indexA, Waypoints[indexA].Roll, m_ControlPoints1[indexA].Roll, m_ControlPoints2[indexA].Roll, Waypoints[indexB].Roll); } Vector3 fwd = EvaluateTangent(pos); if (!fwd.AlmostZero()) { Vector3 up = transform.rotation * Vector3.up; Quaternion q = Quaternion.LookRotation(fwd, up); result = q * Quaternion.AngleAxis(roll, Vector3.forward); } } return(result); }