How do i loop an animation x times based on game logic inside animation blueprint state machine?


I have recently been recreating my animation setup using an animation blueprint. previously it was being driven from a behavior tree but i needed to ad functionality for blending animations.

The following pictures shows my setup.

The SpawnMinionAnimMontage is an attack that is supposed to loop a variable amount of times based on game logic, before playing an exit animation.

How do i play the montage inside my state machine? also how do i detect when it is over so that i can transition beck into idle?

Is a montage the right thing to use for this or can i set up these loops manually in the individual animation state? I may be wrong but it seemed like i couldn’t do it manually because there was nothing to hook up any execution pins to so that i can drive the logic etc…