/// <summary> /// Gets the rotation of a point along the line at the specified length /// </summary> public Quaternion GetRotation(float normalizedLength, LineRotationMode lineRotationMode = LineRotationMode.None) { lineRotationMode = (lineRotationMode != LineRotationMode.None) ? lineRotationMode : rotationMode; Vector3 rotationVector = Vector3.zero; switch (lineRotationMode) { case LineRotationMode.Velocity: rotationVector = GetVelocity(normalizedLength); break; case LineRotationMode.RelativeToOrigin: Vector3 point = GetPoint(normalizedLength); Vector3 origin = TransformPoint(originOffset); rotationVector = (point - origin).normalized; break; case LineRotationMode.None: return(LineTransform.rotation); } if (rotationVector.magnitude < MinRotationMagnitude) { return(LineTransform.rotation); } Vector3 upVector = GetUpVectorInternal(normalizedLength); if (manualUpVectorBlend > 0f) { Vector3 manualUpVector = LineUtility.GetVectorCollectionBlend(manualUpVectors, normalizedLength, Loops); upVector = Vector3.Lerp(upVector, manualUpVector, manualUpVector.magnitude); } if (flipUpVector) { upVector = -upVector; } return(Quaternion.LookRotation(rotationVector, upVector)); }
/// <summary> /// Gets the rotation of a point along the line at the specified index /// </summary> public Quaternion GetRotation(int pointIndex, LineRotationMode lineRotationMode = LineRotationMode.None) { return(GetRotation((float)pointIndex / PointCount, lineRotationMode != LineRotationMode.None ? lineRotationMode : rotationMode)); }