FloatCurveKey

Constructors

NameDescription
new(time: number,value: number,Interpolation: KeyInterpolationMode)Creates a new FloatCurveKey at the given time and value. Interpolation defaults to Enum.KeyInterpolationMode.Cubic when omitted. LeftTangent and RightTangent are left uninitialized; an effective value of 0 is used for them during curve evaluation.

Code Snippet

local curve = Instance.new("FloatCurve")

curve:SetKeys({
    FloatCurveKey.new(0, 0, Enum.KeyInterpolationMode.Linear),
    FloatCurveKey.new(1, 10, Enum.KeyInterpolationMode.Cubic),
})

print(curve:GetKeyAtIndex(2).Value) --> 10

Properties

NameTypeDescription
TimenumberThe time position of this FloatCurveKey along the curve's timeline. Default is 0. Keys are kept sorted in ascending time order; inserting a key at an existing time replaces it.
ValuenumberThe numerical output value at this key's position on the curve. Default is 0.
InterpolationKeyInterpolationModeThe interpolation mode (Constant, Linear, or Cubic) used for the curve segment that begins at this key. Default is Cubic. Switching to a non-Cubic mode automatically clears RightTangent.
RightTangentnumberThe slope of the curve leaving this key toward the next key. Default is nil (an effective value of 0 is used). Can only be set when Interpolation is Cubic.
LeftTangentnumberThe slope of the curve arriving at this key from the previous key. Default is nil (an effective value of 0 is used). Can be set on a key with any interpolation mode.