Multiple State Machines and AnimGraph Questions.

After creating a simple Weapon System using integer values to switch the skeletal mesh of the weapon and move it accordingly, I hit a road block with animations setting this up.
My problem wasn’t switching between these different character gun animations it was having them blend correctly and then more questions came to mind.

  1. Having Multiple State machines in the AnimGraph. What exactly does this mean? What’s the purpose and how do they communicate between each other if there is only one final Animation.
    Should I be switching between these State Machines in the AnimGraph in a switch on int/Enum type way to this final AnimGraph Animation?

  2. If I have one Walk and run animation blended for each one of these upperbody AimOffsets do I need to set it for each one individually or there a node I can use for that?

  3. When I blend my aim offset for my walk and run animations my character’s aimoffset no longer turns slightly left. He only looks up and down.

4.Why…On earth is my characters walk animation slightly moving in the 0 speed position?

  1. When I have a crouch walk and sprint how do I go about blending the crouch with the aim offset? Or is better to have different run animations for different weapons?

Sorry if I’ve loaded this thread with too many questions.

I could show you how I have done a lot of what you are asking about, but it would be way to much for me to type it all out. I could make a video and talk you through what I have done, my system is set up for replication for multiplayer, I guess it will also work for single player games.

It would be a pretty long video, because that is a lot of information, but if you really want me to I might be willing to do it. Also I am only an amateur, so this might not be the exact proper way its supposed to be done, but it does work and is fully functional.

Multiple State Maschines are evaluated concurrently.

You cannot communicate between SMs, but blend multiple SMs together.
I had a State Maschine for the Left Weapon and one for the Right Weapon (Dual Gun Wielding) and blended them together to my main SM via blend bones per Layer

To be able to give the right kind of advice there needs to be a much fuller understanding of the needed game dynamics as to player driven mechanics based on a need for something simple, like a Angry Birds, or more complex, like the next great Assassins Creed, and if the need is for something a lot more complex it’s time to put away the computer and map out the logic block first to figure out how the animation “needs” to migrate through the AnimGraph based on a given state change.

For something simple then it would be possible to do everything using a single state machine but for something a lot more demanding State Machines do not scale very well on impulse additions or work very well as to the need for nested state changes due to the demands of in state arguments necessary to get out of the current nested state. Long way of saying is State Machines do “not” work with data driven requirements if there is a need to change the state with out the need to constantly add arguments to get out of one state and into another with in the migration path.

Adding multiple state machines means that at some point you will be spending much of your time fixing migration bugs, like your character not being able to get out of a state, and will tend to grow to the point that random additions, scaling, will become impossible as the design grows out of control over time.

With out getting into details I would say as part of the building the logic blocks for a much more complex design start with the ideal of excluding the need to add any kind of State Machine to the migration path.

Plenty of nods to work with as far as switching the state goes for switching logic blocks than there is flexibility of driving the final output through the use of multiple state machines so if your thinking you need more than one then it’s time for a rethink as to what will work best with the migration path.

Sure there are nodes to do all sorts of things and once again back to the idea that you need a logic block designed first as to be able to recommend how to get into and out of the block as to “layering” the final output based on the ideal that the character model can only be in a single state at any given time.

A typical layering using a logic block.

Locomotion State

This would be any state layered from the hips down which would be say running, walking,jumping,swimming or any thing that involves translation with in 3d space. Logic wise the player can not be running and walking at the same time so you could use a blend to switch the state using int/Enum or Boolean values.

Action State.

This logic block will be a layer for any action state the occurs from the spin up and would included things like idle pose, firing a weapon, reloading, or any other Action that is not restricted or dependent on the current Locomotion state.

Condition State.

Is the player injured which could be a fork in the migration path from both the Locomotion and/or Action State.

No idea with out seeing the project files.

No idea with out seeing the project files.

Once again the answer is in the logic block design as to how it needs to work in it’s completed form and not what it would take to make it work today. The simple response would to just add a Blend per bone and tell the layer to blend the “Action” state from the hips up.

So the long way around advice do all of your prep work on paper on how the animation needs to migrate from the top down broken down into logic blocks of what needs to go where it it becomes a snap to add the right switches where they need to go as well scale based on need.

I know this is a necro …

For each “State Machine” create a Cache Pose. Then use “Blend Pose by Int”. Hook each State Machine Cache pose into the Blend. Create an Integer var and plug it into the “active child index”. Create a new Cache Pose for the output of the blend. Use this new cache pose as the locomotion down the line.

In the Anim BP event graph create the logic to “Set” and “Change” what state the character should be in. This should be plugged in to “Event Blueprint Update Animation”.

2 Likes

Thanks a lot man! I couldn’t find the precise answer anywhere! Even if it took you 3 years to give the answer and took me 3 more years to find it))

Any idea how to blend between more than 2 states? I’d like to use a different state machine for each NPC in my game and I have 4 at the moment. I was hoping there’d be an option to switch between different cache’s based on an enum but I can’t figure out how.

Hi, right click on the Blend Poses node and you should see “Add Blend Pin” at the bottom.

1 Like