GS_Motion

The playback engine — ticks through tracks, computes per-track progress windows, and manages motion lifecycle.

GS_Motion is the playback engine that drives animation tracks. It ticks through all tracks each frame, computes per-track progress windows based on start time and duration, applies easing curves, and calls Update(easedProgress) on each active track. It handles motion lifecycle from initialization through completion.

For usage guides and setup examples, see The Basics: GS_Core.


API Reference

MethodParametersReturnsDescription
PlayvoidBegin playback from the start.
PlayWithCallbackAZStd::function<void()> cbvoidPlay and invoke callback on completion.
StopvoidStop playback immediately.
InitializeAZ::EntityId ownervoidInitialize all tracks with the owner entity.
UnloadvoidUnload all tracks and clean up.

Fields

FieldTypeDescription
motionNameAZStd::stringDisplay name for the motion.
tracksvector<GS_MotionTrack*>The tracks in this motion.
loopboolWhether playback loops.
onCompletefunction<void()>Completion callback (set via PlayWithCallback).

How It Works

Each frame during playback:

  1. The motion calculates the global elapsed time.
  2. For each track, it computes the track-local progress based on startTime and duration.
  3. If the track is within its active window, the progress is eased using the track’s curveType.
  4. Update(easedProgress) is called on the track with the eased value (0 → 1).
  5. When all tracks complete, OnMotionComplete() is called.

Virtual Methods

MethodDescription
OnMotionCompleteCalled when playback finishes. Override in subclasses for custom teardown.

See Also


Get GS_Core

GS_Core — Explore this gem on the product page and add it to your project.