Skip to content

Keyframing Animations

Coela Can't! edited this page Aug 20, 2021 · 2 revisions

Keyframing Animations

KeyFrameTracks can control floating-point parameters based on a float variable reference. To instantiate a KeyFrameTrack object, specify the max number of parameters to add, the minimum value, the maximum value, the max number of keyframes, and the interpolation method. The available interpolation methods are linear interpolation, cosine interpolation, and step.

// Include header
#include "KeyFrameTrack.h"

// Floating point value to modify
float parameter = 0.0f;

// Instantiate keyframe track
KeyFrameTrack parameterTrack = KeyFrameTrack(10, 0.0f, 1.0f, 10, KeyFrameTrack::Cosine);

// Pass the parameter reference to the keyframe track
parameterTrack.AddParameter(&parameter);

// Add keyframes to the track
parameterTrack.AddKeyFrame(0.0f, 0.0f);
parameterTrack.AddKeyFrame(1.0f, 1.0f);
parameterTrack.AddKeyFrame(2.0f, 0.0f);
parameterTrack.AddKeyFrame(1.3f, 0.25f);

// Update the keyframe track to update the current value of parameter
parameterTrack.Update();