rememberAnimationTrack

fun rememberAnimationTrack(state: AnimationState, index: Int, weight: Float = 1.0f, speed: Float = 1.0f, loop: Boolean = true): AnimationTrack

Adds a weighted track to state's AnimationState.mixer for as long as this call stays in composition, and keeps its weight/index/speed/loop in sync with the arguments. The track is created once and removed automatically when the call leaves composition, so build a blend tree by calling this once per clip and driving weight from your own state. Its clock keeps running across index/weight changes; call AnimationTrack.seek to rewind.

For an imperative (non-Compose) game loop, add tracks with AnimationMixer.addTrack instead.

val anim = rememberAnimationState(initialAnimationIndex = null)
rememberAnimationTrack(anim, walkIndex, weight = 1f - moveSpeed)
rememberAnimationTrack(anim, runIndex, weight = moveSpeed)

Return

The track, e.g. to read its AnimationTrack.progress or AnimationTrack.isFinished.