Canceling an anim on skeletal mesh to play a new anim,

I know I must be overlooking something very simple here, the situation is this: I have a sniper rifle in my FPS project. It has a reload animation where I load rounds one by one into the breach. The gun is animated as a skeletal mesh using “Play Animation” nodes, attached to a socket in the arms mesh, and the arms are animated via state machine and montages.

I have five different anims for arms and gun, depending on how many rounds are needed (reload one, reload two, reload three, etc) and a sixth anim called reload out, where the arms just move the bolt forward and down and we return to idle. There are notifies in all the reload anims to let us know if it’s OK to cancel out and play the “out” animation.

My problem is the “out” animation never plays on the gun - only the arms. Instead, as the arms are playing their “out” montage, the gun finishes whichever reload it was playing (you see floating rounds getting loaded into the breach, bolt goes forward and down).

I’ve tried a couple different things, such as setting up all the gun anims as montages (this actually made things worse - those never seemed to play despite setting a proper slot) and setting up a state machine in a new anim BP for the gun itself. That actually didn’t work as well as using “Play Animation” nodes for things like firing, occasionally the “fire” state would not work and the gun wouldn’t fire.

At this point I’ve spent around 4 hours on the issue and was wondering if anyone out there might have an idea of how to achieve this canceling-out-of-reload functionality. Any advice would be greatly appreciated!

Well, you can try to set an empty state machine for the gun, and add a default slot for montages in anim graph.

There is a known bug, you should open the montages to load them after creating, otherwise they won’t work ingame.

In the events, you can get skeletal mesh and get its anim instance, where you can check if montage is playing/stop any montage/play montage, keep in mind you don’t need to specify a montage when stop or check, if you leave it empty it will stop the current one.

Excellent, thanks for the advice! Will try that today. Also have you used “Sections” at all in montages? Was thinking of looking into that as well. Was poking around the forums and from what I can tell, loading the rounds could theoretically just be a loop of one round going in, and then a section marked “out” where the bolt goes back forward. Though I think I tried this with my shotgun at one point and ultimately decided on the “brute force” method of anims for each quantity of shells needed, which you can break out of using notifies.

Anyway, thanks again for taking the time to respond, I really appreciate it!

Well, the sections are not blending together, i mean you would not put 2 different animations on a section, sections are needed if you have 1 big animation that cut aparts, where you would like to process it forward or backward by some events, like (start/mid/loop/end), where blend is not needed.

Actually you can just use single loop montage for hand and gun while loading rounds, and when its no longer needed, just play another montage on them(it will stop the current one), or just cast to the anim instance, and stop montage with blend.

Thanks - actually that is exactly what I did. My problem was that I was playing the montages for reloading by casting to the anim instance of the weapon mesh in one area of the event graph, but I was doing the “reload out” montage on another anim instance of that mesh in a different area of the event graph. So each they didn’t know the other existed. By forking the anim instance pins for the reload anims and dragging them all the way over to where the reload out montage was getting called, it worked. The reload out montage takes over and interrupts the previous montage being played in the anim instance. Thanks again for your help!

no problem mate, you can also save anim instance reference as variable after getting it(by beginplay or other way), thus way you can always purely call it to play your anim, btw also you don’t need to cast to specific anim instance, play/stop/check montage node works directly from anim instance reference itself, good luck.

Thanks! I’ll see if I can clean things up using that method this weekend.