Skip to content

Api > AnimationCurve > MoveKey()


AnimationCurve.MoveKey(number index, Keyframe key)⚓︎

Removes the keyframe at index and inserts key.

Parameters:⚓︎

Name Type Description
index number The index of the key to move.
key Keyframe The key (with its new time) to insert.

Returns:⚓︎

type Description
number The index of the keyframe after moving it.

Usage⚓︎

---@type AnimationCurve
local animationcurve;

---@type number
local index;

---@type Keyframe
local key;


local val0 = animationcurve.MoveKey(index, key)

Extra Detail⚓︎

If a keyframe already exists at key.time, then the time of the old keyframe's position key[index].time will be used instead. This is the desired behaviour for dragging keyframes in a curve editor. Returns the index of the keyframe after moving it.