Download

Advice on when to choose to use a state machine versus an animation montage - Help!

Hey guys,

Ive read through the documentation and seen a few good examples on animation montages, such as the shotgun with the loopable ‘middle’ section. I understand how an animation montage does this within a single asset, but what I think the documentation dosent give a great example of is why you would use a montage when there are other ways to do that exact same thing.

For example, why wouldnt you just use a state machine to play the start, loop the middle based on the number of shells left to load, then play the end, and back to idle. What im confused is fundamentally why state machines are a worse or better choice than a montage.

Im working on a game at the moment, and have set up multiple detailed locomotion blueprints for the 3rd person, and understand how they work. Its all done with Blendspaces and works really nice! Im now working on a slightly different thing though. Im trying to set up my first person AK74 animations.

I have first person arms, and an AK74, which I have a good animation set for.

Just as an example, here are some of the animations I have.

Run
Walk
Jump
Shoot hip fire (x3) for variation
Shoot ADS (x3)
Idle
Inspect
Reload wet
Reload dry

Now ive set up an animation BP for both the arms and gun, and made it work with almost all of these animations as states, being driven by simple variables and rules on the transitions, and it works. The first issue ive come across was shooting.

I tried to use the blend on int node to play random shots, but quickly found that there is no way to reset an animation in a state machine once ive blended out of it, so essentially I couldnt fire automatically. From a bit of research, it appears a montage can solve this issue, as afaik, theres ultimately more control programatically with whats going on with your animations there?

So heres the question really. Why would I use a montage for the other stuff, such as reload. Even for a shotgun, I can still use states to drive the looped part? What about the other stuff, run, walk jump, Im unsure on what that cut-off point is where it makes more sense to use montages fired from the event graph than use a nice clean state machine.

The only example I could think of for why you would want to do a reload via a montage, was for example, as you level up, you can perform the reload animation a little bit faster, and you can set the rate of the montage based on variables, where as you simply couldnt do that inside a state machine.

Thank you in advance for any help, and I hope it helps others whom may come across a similar question in the future and come across this thread!

Cheers!

OK some basic understanding to start :smiley:

In games development there is no such thing as best practice unless the given need for functionality is with in some kind of context in with a purpose of design needs to be served. A way of saying that there is no good, better, best with out context so in general be it a state machine or montage but since you ask

For example, why wouldnt you just use a state machine to play the start, loop the middle based on the number of shells left to load, then play the end, and back to idle. What im confused is fundamentally why state machines are a worse or better choice than a montage.

With in that context there is no telling how many sequences the reload of a shot gun needs to make depending on how many shots the player has made as to reload timing based on what it takes for a full reload. If the player has made 3 shots of a 5 shot load then only 3 cycles are needed where if a full reload is required then the reload will cycle 5 times.

Why do it all with in the same montage?

A typical problem is if a migration path as to a state change it can cause the take to pop is part of the mechanic is to use the reload as a cool down and lock the reload into the montage until the cycle is complete.

The big thing though is a montage is considered an action state which can occur at anytime during a locomotion state.

You could do the same function in a state machine but doing so makes the reload function a unique requirement as to an action state change that can be handled by a single montage slot. You have 100 action states using state machines you would need 100 migration paths for each state change. With a Montage you can add thousands of action state changes using just one slot.

So in general anything locomotion related state machines work best for the most part where for action states montages as they can be layered at any point with in the locomotion state.

As general advice learn animation layering and what it is with in Unreal 4 as anything else after that would make total sense. Much easier to decided what to do with in a context of purpose :wink:

Sorry for the late reply, I’ve been giving montages a thorough testing and am seeing the usage benefits of them. Thank you so much for this fantastic reply, hopefully it will also help many others who run into this question in the future, it was extremely informative! Thanks Frankie!