Change State Machine Conduit Usage

The state machine system can lead us to create spaghetti chaos like the one we see in the picture. However, that’s not the way everyone uses them. I would suggest, rather than improving them, give users more learning material on how to take the most of them.

A simple blend poses by Bool, using a “Crouch” Boolean would already half your graph, allowing you to reuse those states.


I’ll give you here example of a more expandable StateMachine which would allow you to have not only 2 states, but as many as you want, also could be shared amongst different characters.

Did you know there is a way to expose a pin of an animation or blend space node? I find it useful to connect different context sensitive animations. This way, you could have the same idle state playing your “Standing” and your “Crouching” animations. It’s a variable right? so just store those animation names via the eventgraph. Using something like this would already reduce your graph by half, and it would also make it scalable, in case one day you decide you need your character to swim.

As you can see here, it could be your standing walkrun and your crouching walkrun. Blendspaces accept a variable, like speed, this means you could have your land2idle, land2walk, and land2run animations in a BlendSpace rather than in 3 different states.

Let’s go back to the pins tho, BlendSpaces are explained somewhere on youtube, a google search could def help you with that. How do we get Animations in those slots?
What I did was create a few **structs ** so I could avoid hard coding any of those animation names. This also allows me to change not only character states, but also characters themselves. (This is a bit more complex so I won’t go into detail in this post)

Structs.JPG

These are the blueprint nodes we will need to store our animations.
The Structs are have in them Blendspace and animations variables, depending on what we want to use in the AnimGraph. I also add a “loop” boolean, you can add as many extras as you want, additive animations… anything you can imagine.

The blueprint, AnimList, is a list of animations, which will hold ALL our animations, all the states, all the possibilities…

We then add it as a CLASS variable on our AnimBlueprint and we can get it’s defaults, all those animations!!

3c072cea1101b7c00277a0e28504e61befe26f7a.jpeg

We then need a “current animations” struct so we can plug the animation names to that final slot we’ll use on our state machine. Here I’ve used a simple Boolean to change which ones to store, but you if you have more states you can use enums, structs, you can change anims based on speed, have a flying movementset if the character is in the air, or a swimming one if he/she is underwater.

Now we have our list of anims stored in our struct variable ready to use them in our animation state machine,

like so:

As you can see here, the same blendspace allows me to play crouch and standing idles, halving all your different states, and if you then combine the lands to use a single state and a blendspace your spagetthi becomes a very tidy set of just:

  1. Idle
  2. Idle2move (if you want to have more control)
  3. WalkRun
  4. Jump
  5. Fall
  6. Land.

I hope it helps!