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!