# Cleaning Up State Machine Spaghetti

**URL:** <https://forums.unrealengine.com/t/cleaning-up-state-machine-spaghetti/300647>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [December 5, 2014, 5:58am UTC](https://forums.unrealengine.com/t/cleaning-up-state-machine-spaghetti/300647 "2014-12-05T05:58:51Z")\
**Posts on this page:** 10\
**Page:** 2

<div class="post-metadata">

**Author:** ![Zooch](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Zooch](https://forums.unrealengine.com/u/Zooch)\
**Post date:** [December 15, 2014, 5:13pm UTC](https://forums.unrealengine.com/t/cleaning-up-state-machine-spaghetti/300647/21 "2014-12-15T17:13:31Z")

</div>

The blend based on int value was my issue as well. That’s what I originally tried to do and failed with, then I recently tried again using the bool value in your first image and it seemed to work fine, so I figured I just screwed it up the first time when using blend by int.

Maybe it’s actually bugged though. I wonder if I could use blend by bool like 8 times in a row 😃

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2a254ae9](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2a254ae9](https://forums.unrealengine.com/u/anonymous_user_2a254ae9)\
**Post date:** [December 15, 2014, 5:25pm UTC](https://forums.unrealengine.com/t/cleaning-up-state-machine-spaghetti/300647/22 "2014-12-15T17:25:30Z")

</div>

Sir, you want to take the responsibility to post that bug or should I? 🙂  
At least I hope it’s a bug, worst case we learn how to do it properly.

As for 8 bools, let us know if you try 🙂

---

<div class="post-metadata">

**Author:** ![Zooch](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Zooch](https://forums.unrealengine.com/u/Zooch)\
**Post date:** [December 15, 2014, 6:49pm UTC](https://forums.unrealengine.com/t/cleaning-up-state-machine-spaghetti/300647/23 "2014-12-15T18:49:43Z")

</div>

I’ll post it. I’m pretty slammed at work through Christmas, but I hope to try the 8-bool approach soon 🙂

---

<div class="post-metadata">

**Author:** ![Zooch](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Zooch](https://forums.unrealengine.com/u/Zooch)\
**Post date:** [December 15, 2014, 7:01pm UTC](https://forums.unrealengine.com/t/cleaning-up-state-machine-spaghetti/300647/24 "2014-12-15T19:01:43Z")

</div>

> **[Select node not working in custom blend transition (AnimBP)](https://forums.unrealengine.com/questions/147697/select-node-not-working-in-custom-blend-transition.html)**
>
> This is turning into a popular problem. You can see the spawn of this conversation at this AnswerHub link: Cleaning Up State Machine Spaghetti - Programming & Scripting - Epic Developer Community Forums We’ve built a custom blend transition to...

Posted.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2a254ae9](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2a254ae9](https://forums.unrealengine.com/u/anonymous_user_2a254ae9)\
**Post date:** [December 15, 2014, 7:09pm UTC](https://forums.unrealengine.com/t/cleaning-up-state-machine-spaghetti/300647/25 "2014-12-15T19:09:06Z")

</div>

Thanks for the link, really hope it’s only a bug, or maybe a not finished feature and soon it will work. Even now the animation system in UE is fantastic, if this feature would be fixed, it would be getting quite close to being perfect 🙂

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_01dd28a6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_01dd28a6](https://forums.unrealengine.com/u/anonymous_user_01dd28a6)\
**Post date:** [June 17, 2015, 10:29pm UTC](https://forums.unrealengine.com/t/cleaning-up-state-machine-spaghetti/300647/26 "2015-06-17T22:29:36Z")

</div>

Select is not supported in animations like that. You HAVE TO use a blend.

---

<div class="post-metadata">

**Author:** ![Kain\_Shin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kain\_Shin](https://forums.unrealengine.com/u/Kain_Shin)\
**Post date:** [May 12, 2016, 7:09pm UTC](https://forums.unrealengine.com/t/cleaning-up-state-machine-spaghetti/300647/27 "2016-05-12T19:09:02Z")

</div>

I’m just starting out, but one of the things I’m doing now in this early phase to mitigate complexity is making sure that logical animation state is controlled by a single enum in code. I then use a single conduit to transition to any state based on that one enum. The anim state machine will transition out back to the conduit if that enum changes into one that is not meant for that state.

This is a very early example…  
 ![starburst pattern](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/4/d/54dd1038e89651821d23846eeea7b0e31f789717.png)

In short, I made sure that all gameplay logic existed outside of this AnimGraph and only in code.

Sticking with this single-enum starburst pattern allows me to add states with no dependency on current state since that complexity is handled by code, which is way easier to manage than boxes and lines. If code is not an option, you may still benefit from this type of pattern by managing that enum in a separate blueprint that decouples gameplay logic from animation logic.

---

<div class="post-metadata">

**Author:** ![Flash7](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Flash7](https://forums.unrealengine.com/u/Flash7)\
**Post date:** [March 20, 2017, 10:31pm UTC](https://forums.unrealengine.com/t/cleaning-up-state-machine-spaghetti/300647/28 "2017-03-20T22:31:03Z")

</div>

So, I also did a research before getting into that spaghetti mess. I would add to conduits and selects, also nested State Machines. I found this example, that shows how a complicated state machine can be split into multiple: [UE4 Adventure Kit v2.0 Integration Tutorial - 07 - Anim Blueprint - Anim Graph - YouTube](https://www.youtube.com/watch?v=MyqZIRH5UP8)

---

<div class="post-metadata">

**Author:** ![Noisegrinder](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Noisegrinder](https://forums.unrealengine.com/u/Noisegrinder)\
**Post date:** [June 14, 2018, 3:15am UTC](https://forums.unrealengine.com/t/cleaning-up-state-machine-spaghetti/300647/29 "2018-06-14T03:15:43Z")

</div>

This might be the best solution to this problem. It makes the state machine more organizable and more generic, yet it sacrifices flexibility for specific requirements. For instance, if I have a very special animation to only handle the transition from “Jumping” to “Dead” it might need extra care for this structure. But compared to managing an unreadable spaghetti mess, I’d rather have those extra work!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_ad3dde20](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_ad3dde20](https://forums.unrealengine.com/u/anonymous_user_ad3dde20)\
**Post date:** [March 27, 2019, 7:35pm UTC](https://forums.unrealengine.com/t/cleaning-up-state-machine-spaghetti/300647/30 "2019-03-27T19:35:54Z")

</div>

Oh wow, this is exactly what I’ve been looking for! Thanks so much for this comment.

For anyone directed here from search results, Flash7’s link is probably what you’re looking for!

[Previous page](https://forums.unrealengine.com/t/cleaning-up-state-machine-spaghetti/300647.md?page=1)
