Skip to main content

Class AnimationCurveExtension

Provides extension methods for the AnimationCurve class.

public static class AnimationCurveExtension

Inheritance​

Methods​

EvaluateTime(AnimationCurve, float, float, float, float)​

Finds the time on the AnimationCurve at which the curve evaluates to the specified target value. Uses a binary search approach, assuming the curve is monotonic (strictly increasing or decreasing) within the search interval.

public static float EvaluateTime(this AnimationCurve curve, float targetValue, float startTime = -1, float endTime = -1, float elipson = 0.001)

Parameters​

NameTypeDescription
curveAnimationCurveThe animation curve to evaluate.
targetValuefloatThe value on the curve you want to find the corresponding time for.
startTimefloatOptional start time for the search interval; if negative, the curve's first key time is used.
endTimefloatOptional end time for the search interval; if negative, the curve's last key time is used.
elipsonfloatThe acceptable margin of error when matching the target value.

Returns​

float — The time at which the curve approximately reaches the target value, or -1 if no solution is found within the interval.

Remarks​

This method works reliably only if the curve has a unique time for each value within the specified range.

  • Methods
    • EvaluateTime(AnimationCurve, float, float, float, float)