enter method
entity enters state, blending from what it played over fade
seconds where it can.
Implementation
@override
void enter(Entity entity, AnimatorState state, {double fade = 0}) {
final player = entity.getComponent<AnimationPlayerComponent>()!;
final tree = state.blend;
if (tree == null || tree.motions.isEmpty) {
player.play(state.clipName, fade: fade, restart: true);
} else {
// Weights come with the first update; until then the first motion.
player.playBlend(
[for (final m in tree.motions) m.clip],
[for (var i = 0; i < tree.motions.length; i++) i == 0 ? 1.0 : 0.0],
speeds: [for (final m in tree.motions) m.speed],
fade: fade,
);
}
// Set after playing, so what fades out keeps its own speed and looping.
player
..playingSpeed = state.speed
..playingLoop = state.loop ?? true;
}