Roblox UtilitiesDevlHub Roblox Documentation

Class

FloatCurve

Inherits
Instance › Object
Memory category
Instances

A sorted list of time-value pairs that define a curve. Used to animate a single numerical value.

An instance representing a 1D float curve encoded via a sorted list of FloatCurveKeys. The shape of the interpolation curve between two keys is determined by the FloatCurveKey.Interpolation type.

Properties 1#

LengthintNumber of keys in the float curve.ReadSafeReadOnlyNotReplicated

Length: int#

ReadOnlyNotReplicatedReadSafe

Number of keys in the float curve.

Methods 7#

GetKeyAtIndexReturns a copy of a key at a given index.
GetKeyIndicesAtTimeReturns the index of the last and first key of a period of time.
GetKeysReturns a copy of all the keys in the FloatCurve as a Luau array of FloatCurveKeys.
GetValueAtTimeSamples the float curve at a given time passed as argument.
InsertKeyAdds the key passed as an argument to this curve. If a key at the same time is found, it will be replaced.
RemoveKeyAtIndexRemoves a given number of keys starting from a given index.
SetKeysResets this curve's keys using the FloatCurveKey array passed as an argument.

GetKeyAtIndex(index: int): FloatCurveKey#

Returns a copy of a key at a given index.

NameTypeDefaultDescription
indexintOne-based index of the key to retrieve.
Returns

GetKeyIndicesAtTime(time: float): Array#

The first item in the returned array is the index of the last key with time less than or equal to time (or the lesser of either 1 or the curve length if no key was found). The second item in the returned array is the index of the first key with time greater than or equal to time (or the curve length if no key was found satisfying the inequality).

NameTypeDefaultDescription
timefloatTime value to locate within the curve's sorted keys.
Returns
  • Array — Array of two one-based indices that bracket time: the last key at or before time and the first key at or after it.

GetKeys(): Array#

Returns a copy of all the keys in the FloatCurve as a Luau array of FloatCurveKeys.

Returns

GetValueAtTime(time: float): float?#

Samples the float curve at a given time passed as argument.

NameTypeDefaultDescription
timefloatTime at which to sample the curve.
Returns
  • float? — Value of the curve at the requested time.

InsertKey(key: FloatCurveKey): Array#

Adds the key passed as an argument to this curve. If a key at the same time is found, it will be replaced. In the returned array, the first value is true if a key was added or false if a previous key was replaced; the second value is the index at which the marker was added.

NameTypeDefaultDescription
keyFloatCurveKeyFloatCurveKey to insert.
Returns
  • Array — (see description) .

RemoveKeyAtIndex(startingIndex: int, count: int = 1): int#

Removes a given number (count) of keys starting from the startingIndex index and returns the number of keys that were removed.

NameTypeDefaultDescription
startingIndexintStarting index from which to remove keys.
countint1Number of keys to remove.
Returns
  • int — Number of keys removed.

SetKeys(keys: Array): int#

Resets this curve's keys using the FloatCurveKey array passed as an argument. Keys in the keys array are sorted in ascending time order before insertion, and keys at duplicated times are removed in a stable manner.

Returns the number of keys actually inserted. Keys previously stored in this curve are removed before the keys passed as arguments are added.

NameTypeDefaultDescription
keysArrayArray of FloatCurveKeys.
Returns
  • int — Number of keys inserted.

Inherited members#

Inherited from Instance 58
Inherited from Object 6
Properties (2)

ClassName, className

Events (1)

Changed