Does StateTree Stop Montages and Trigger OnMontageEnded on the AnimInstance?

Hi all,

I’m working on an NPC combat system using StateTree in UE5 and running into what I believe is an unintended montage interruption.

My setup:

  • NPC attacks are driven by a StateTree (LST_Combat) with an Attack state that plays an attack montage
  • OnMontageEnded on the AnimInstance is bound in BPC_Attack (an ActorComponent) to reset an IsAttack flag
  • The IsAttack flag is set to true at the start of StartAttack and reset to false in HandleMontageEnded, and acts as the sole gate to prevent consecutive attack montages from being played

The bug:
NPCs can spam attacks consecutively. The IsAttack flag is supposed to block StartAttack from being called again while an attack montage is already playing, but this prevention does not work for AI-controlled characters. The issue does not occur on the player character.

My question:
Does StateTree internally call StopAnimMontage (or equivalent) during state transitions, which would trigger OnMontageEnded with bInterrupted=true on the AnimInstance?

I have no explicit StopAnimMontage in any Task or Evaluator. There is also no StopAnimMontage in any BTTask AbortTask or StateTree Exit logic. The issue is highly reproducible rather than timing-dependent, so I suspect something other than a race condition is at play.

Any insight would be greatly appreciated.

Thanks!

StateTree does not have anything in its internals that would know about AnimMontages or affect them. Can you share the task you are using to play the anim montage? Is it possible the StateTree transitions immediately out and re-enters the same state causing the attack and/or its animation to replay right away?

Additionally, StateTree is wired into the Rewind Debugger. This shouldall you to be able to inspect an AI NPC who has the continuous attacking behavior to see if anything shows up between its animation tracks and StateTree logic. It will also show exactly what is happening at each tick in a StateTree to help track if the StateTree succeeds in the state then immediately re-enters.

-James