Roblox UtilitiesDevlHub Roblox Documentation

Data type

FloatCurveKey

A time-value pair used with FloatCurve instances.

A time-value pair used with FloatCurve instances.

The Interpolation property dictates the interpolation mode for the segment started by this key and ended by the next key on the curve. Each segment may use a different interpolation mode.

The LeftTangent and RightTangent properties apply to the cubic interpolation mode and define the desired tangent (slope) at the key. Different left and right values can be used to encode discontinuities in slope at the key. Attempting to set a RightTangent value on a key that doesn't use the cubic interpolation mode will result in a runtime error. It is possible to set the LeftTangent property on any key, as it will be used should the preceding segment use cubic interpolation.

Constructors 1#

newReturns a new FloatCurveKey from the given time and value.

new(time: number, value: number, Interpolation: KeyInterpolationMode)#

Creates a new FloatCurveKey at a given time and value. LeftTangent and RightTangent are left uninitialized and, if not initialized, tangent values of 0 will be used when evaluating the curve.

NameTypeDefaultDescription
timenumberTime at which to create the new FloatCurveKey.
valuenumberValue of the new FloatCurveKey.
InterpolationKeyInterpolationModeThe interpolation mode for the curve segment starting at this key. Defaults to Cubic when omitted.

Properties 5#

InterpolationKeyInterpolationModeThe key interpolation mode for the segment started by this FloatCurveKey.
TimenumberThe time position of this FloatCurveKey.
ValuenumberThe value of this FloatCurveKey.
RightTangentnumberThe tangent to the right of this FloatCurveKey.
LeftTangentnumberThe tangent to the left of this FloatCurveKey.

Interpolation: KeyInterpolationMode#

Specifies the interpolation mode used for the curve segment that begins at this key and ends at the next key on the FloatCurve. Each segment of the curve can use a different interpolation mode. The default value is KeyInterpolationMode.Cubic.

The available modes are:

  • Constant — the segment holds the value of this key until the next key.
  • Linear — the segment linearly interpolates between this key's value and the next key's value.
  • Cubic — the segment uses a cubic Hermite spline defined by this key's RightTangent and the next key's LeftTangent.

Changing this property to a non-cubic mode automatically clears the RightTangent of this key, because only cubic segments use a right tangent.

Time: number#

The time position of this FloatCurveKey along the curve's timeline. The default value is 0. Keys within a FloatCurve are kept sorted in ascending time order; if you insert a key at a time that already exists on the curve, the existing key at that time is replaced.

Value: number#

The numerical output value at this key's position on the curve. The default value is 0. When a FloatCurve is sampled at this key's Time, the curve evaluates to this value (subject to any interpolation with neighboring keys depending on the sampling time).

RightTangent: number#

The slope of the curve leaving this key toward the next key. The default value is nil, which means the tangent is automatically computed (an effective value of 0 is used during evaluation). This property can only be set when Interpolation is KeyInterpolationMode.Cubic; attempting to set it on a key with Constant or Linear interpolation raises a runtime error. Pairing a different RightTangent value on this key with a different LeftTangent value on the next key creates a discontinuity in slope (a "corner") at the next key.

LeftTangent: number#

The slope of the curve arriving at this key from the previous key. The default value is nil, which means the tangent is automatically computed (an effective value of 0 is used during evaluation). Unlike RightTangent, this property can be set on a key with any interpolation mode, because the preceding segment may itself use cubic interpolation and therefore needs a defined left tangent at this endpoint.