I feel like I am missing something obvious, but here is what I want to happen:
1. Have a montage with 3 sections: an Intro, an Idle, and an Outro.
2. When the montage starts, it plays the Intro, then goes into looping the idle until some other part of the code decides the NPC is done with this behavior.
3. When (or I guess technically right before/as) the montage ends, play the Outro section.
An example scenario would be having an NPC sit in a chair. They need to play the intro animation for sitting down into it. Then a looping idle while sitting. Then a “standing back up” anim when the sitting behavior is interrupted or called as finished in some way.
I currently have points 1 and 2 working. The Idling section is set up to loop in on itself in the Montage Sections:
My issue/question is getting #3 to work.
From research I found the “Montage Set Next Section” node, whose tooltip even cites this scenario
I can get it to work if I hook it up right after the Play Montage node (for the purposes of just proving to myself it works at all and I’m passing through all the right data), like so:
However, obviously, this doesn’t accomplish what I need, because of course it will fire off right when the Play Montage node is called, which means my Idle loop plays once then goes immediately to the Outro and the montage is finished. But I need to accommodate situations where the NPC needs to run the Idle for an indefinite amount of time, until some external event (such as in its AI behavior) says “ok stop this now and do something else”.
For testing purposes I press a debug key to call Stop Anim Montage, which triggers the On Interrupted output of Play Montage. Problem is, once this happens, (I think) the montage considers itself “done”, and so running Montage Set Next Section after this is pointless because the Outro will never play.
The only hacky workaround I can think of is just break the Outro animation out into its own montage and play that manually after On Interrupt in the BP. But that feels clunky and also like it’s sort of sidestepping what Montages were designed for? Any suggestions appreciated.