Cleaning Up State Machine Spaghetti

Hi guys,

I have a state machine with roughly 75 states that controls my entire character locomotion system. I have so many because I have start/stop animations for each direction and each movement type, as well as jump/fall cycles for everything. I also have transition animations between movement types.

It all looks pretty as hell in-game when it works, but my state machine is a huge mess. Here’s an old picture of my state machine graph, with ~30 of my 75 states:

Now imagine double the states and quadruple the little arrow lines. If I have to change one “thing” that affects 16 states, it takes me 45 minutes to just search for all the transition rules and make the change.

Do you guys have any tips for cleaning up this mess? I, the creator of the state machine, can hardly work with it without getting confused and changing the wrong rule. There’s no possible way I could hand this to someone else to work on. Keep in mind the picture I’m showing you is about 25% of the current state machine size.

That would be so mean.

The animation updates from 4.6 should handle the transitions for you. Look at the release notes for details.

Can you show me where in the release notes it discusses more efficient handling of complex state machines (or transitions)? I seem to be missing it - scrolled through the release notes twice and did some control+F keyword searches with very limited results.

Pinging this again.

Just popping in to say I totally feel your pain.

For me, it isn’t even the NUMBER of states that does it, it’s managing the transitions between them. The inability to adjust the curvature of the state transition lines, and the fact that transition arrows just sort of hover next to them rather than being visibly connected, makes it nigh impossible to figure out which thing I need to click on to adjust any given transition.

Yeah your image is much closer to what mine looks like now. Pretty similar to my Christmas lights situation:

Upvoted and following as I’m curious about Epics workflow.

My only potential recommendation would be to use some additive montages for certain one off situations when there is a default blend and not a premade transition out animation such as Dodging, Dashing, etc.

If you override upper body torso, head, arms, etc with certain additive slots you might not need certain transitions.

You could setup all those transitions inside the “Blend Graph” of the “Transition Rule” itself to clean it up a bit.

Edit: A picture =>

Is that in master branch or something? Its not in promoted.
EDIT: I missed changing the blend logic to custom.

It’s 4.6 binary and I guess the feature is not even new in 4.6
Edit: I’m almost sure it was there even in 4.5.1

Nah, I actually have a weird workflow that uses a LOT of transition notifies.

Basically, what I do is I control a lot of the character movement itself with the anim graph. I take inputs, feed them to the anim graph, let the anim graph attempt to drive states accordingly, and then use Anim Notifies or Transition Notifies to return information to the character BP to do the actual movements. This lets me control the “player state” in a sane way (i.e. if I don’t want the player to be able to double jump from a dodge, reload from a dash, etc., I simply don’t allow those state changes to happen period), though obviously it complicates the state machine a little bit.

It’s always “been there”, but the thing is there’s no documentation on it and it’s really unclear how exactly it works. I’ve tried several times to figure it out and have been unable to; and as a result, I’ve got several transition states that I feel are pretty irrelevant but I’ve been unable to eliminate them since I can never seem to get the Blend Graph to show like yours is.

I’m in the same boat with this. I knew about this existing and have poked around myself but never got logical results. There doesn’t seem to be any documentation on this that I can find.

What didn’t work for you? I guess I may have not yet give the feature enough time to reveal it’s problems. But so far it looks to work pretty well, only thing I wish is if there would be a way to setup the overall blend time from within the blend graph based on the length of the transition animation used in the blend graph.

Under the “Root Motion from Everything” heading. I was under the impression that the op was talking about animation transitions. The new should handle the animation transitions, which should in turn make the state machine a little less messy, I would think.

I’m not making a single player game, so I can’t really make use of Root Motion From Everything. I’m also not blending montages, just the animation sequences themselves. I could hypothetically turn all of those animations into a montage I guess…

I just needed to get out of my own way. I’m working on blending two animations now based on simple logic from the AnimGraph.

I do have two questions though - why would you use the Get Source State Pose and Get Destination State Pose nodes that automatically generate?

Also, If you have a custom blend graph that plays different animations based on simple logic, and this all happens inside the transition, does it play the resulting animation (from the custom blend graph) then move to the actual state animation? Or does it just determine which animation to play once it hits the node its transitioning to?

I’m hoping it’s the former, but that means you can actually play animations in the transitions as well as the states.

Get Source State Pose and Destination Pose are there probably so that you can actually blend between the state animation and transition animation used in the blend graph. If you notice you have 3 different options in the Source/Destination Pose - you can ask for last/first frame pose, you can constantly play the source and destination animations (I guess until the transition is over) and you can also ask for specific number of poses where last is kept as frozen.
I think this is meant for two different purposes, one if you have a transition animation which doesn’t need to blend because it starts on the same frame as the animation from which you are transitioning and you make sure that the animation you are transitioning from will play to the end where it has the same pose as the first frame of your transition animation (well, I guess ideally you remove one of the same frames… either last frame of the animation or first frame of the transition animation). The other option, using the source/destination poses is probably meant for transitions where the poses/frames between source animation, transition animation and destination animation can’t be matched with certainty and so you have to blend them with some kind of crossfade logic.

As for the second question, I’m not sure I understand the point. I mean what is the core difference between the two options you are asking if it happens one way or the other?

An example will probably clear the air:

Let’s say you have an Idle animation, a WalkLeftStart_LeftFoot animation, and a Walk blend space. Let’s assume you have the other 3 WalkStart directions for each the Left and Right feet, so 8 total WalkStart animations.

Can you, while using the custom blend graph, determine which of the 8 WalkStart animations should be playing and then play that animation, then go into the WalkBS? Or does it not function this way?

So I have some mixed results. The following stuff from the screenshot works (I know it’s not exactly what you wanted):

The next thing is probably what you want, but unfortunately it doesn’t work. Notice the “Note” on the blend result node.

It “feels” like it should work, but can’t figure out why it doesn’t. Hopefully it’s “just” a bug. If this would work, I think it would be quite handy for taming the spaghetti monsters.