ValueCurve
A sorted list of time-value pairs that define a curve. Used to animate a any type of value.
| Memory category | Instances |
|---|
Member index 11
Description
An instance representing a 1D value curve encoded via a sorted list of ValueCurveKeys. The shape of the interpolation curve between two keys is determined by the ValueCurveKey.Interpolation type.
Not all value types (for example, strings and other non-numerical types) may perform Linear or Cubic interpolation. These types will revert to Constant interpolation if necessary.
History 12
- 695 Add SetKeys
- 695 Add RemoveKeyAtIndex
- 695 Add InsertKeyValue
- 695 Add InsertKey
- 695 Add GetValueAtTime
- 695 Add GetKeys
- 695 Add GetKeyIndicesAtTime
- 695 Add GetKeyAtIndex
- 695 Add
- 695 Add ValueType
- 695 Add Length
- 695 Add ValueCurve
Members 11
GetKeyAtIndex
| Parameters (1) | ||
|---|---|---|
| index | int | |
| Returns (1) | ||
| ValueCurveKey | ||
Returns a copy of a key at a given index.
| Thread safety | Unsafe |
|---|
History 1
- 695 Add GetKeyAtIndex
GetKeyIndicesAtTime
| Parameters (1) | ||
|---|---|---|
| time | float | |
| Returns (1) | ||
| 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).
| Thread safety | Unsafe |
|---|
History 1
GetKeys
| Parameters (0) | ||
|---|---|---|
| No parameters. | ||
| Returns (1) | ||
| Array | ||
Returns a copy of all the keys in the ValueCurve as a Luau array of ValueCurveKeys.
| Thread safety | Unsafe |
|---|
GetValueAtTime
| Parameters (1) | ||
|---|---|---|
| time | float | |
| Returns (1) | ||
| Variant? | ||
Samples the value curve at a given time passed as argument.
| Thread safety | Unsafe |
|---|
History 1
- 695 Add GetValueAtTime
InsertKey
| Parameters (1) | ||
|---|---|---|
| key | ValueCurveKey | |
| Returns (1) | ||
| 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.
If there are not yet any keys, then the key may be added. If keys exist,
the type of the value must match those of existing keys; otherwise a
message is printed and {false, -1} is returned.
| Thread safety | Unsafe |
|---|
InsertKeyValue
| Parameters (3) | Default | |
|---|---|---|
| time | float | |
| value | Variant | |
| keyInterpolationMode | KeyInterpolationMode | Constant |
| Returns (1) | ||
| Array | ||
Creates a ValueCurveKey from the given arguments and inserts it
in 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.
If there are not yet any keys, then the key may be added. If keys exist,
the type of the value must match those of existing keys; otherwise a
message is printed and {false, -1} is returned.
| Thread safety | Unsafe |
|---|
History 1
- 695 Add InsertKeyValue
Length
| Type | Default | |
|---|---|---|
| int | 0 | |
Number of keys in the value curve.
| Thread safety | ReadSafe |
|---|---|
| Category | Data |
| Loaded/Saved | false/true |
RemoveKeyAtIndex
| Parameters (2) | Default | |
|---|---|---|
| startingIndex | int | |
| count | int | 1 |
| Returns (1) | ||
| int | ||
Removes a given number (count) of keys starting from the startingIndex
index and returns the number of keys that were removed.
| Thread safety | Unsafe |
|---|
History 1
- 695 Add RemoveKeyAtIndex
SetKeys
| Parameters (1) | ||
|---|---|---|
| keys | Array | |
| Returns (1) | ||
| int | ||
Resets this curve's keys using the ValueCurveKey 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.
The keys must all contain values of the same type. And that type must
match any existing keys. Otherwise a message is printed, the keys are not
added, and 0 is returned.
| Thread safety | Unsafe |
|---|
ValueType
| Type | Default | |
|---|---|---|
| string | nil | |
Read-only value indicating the type held in this curve, or the string
"Nil" if there are no keys.
| Thread safety | ReadSafe |
|---|---|
| Category | Data |
| Loaded/Saved | false/true |