State Trees in Unreal
- #unreal #gamedev #state-machines
- 187 words, Read time 0 minutes, 56 seconds
Can't wait for the upcoming holidays.
I was building something at work that needed clear, distinct stages, the kind of thing that runs like a show or a stage play: this happens, then that happens, then we move on. My first instinct was to roll a state machine from scratch, the way people would back in Unity.
Then I found out Unreal ships with State Trees built in, and it handed me most of what I was about to write by hand. Conditional transitions, branching hierarchical states, and modular design to scale up and down. All the parts I was too lazy to build, already there.
The workflow is pretty simple. You define these little things called Tasks, drop them into a State, and when that State is entered its Tasks run in the order and manner you set up. That's basically it. No enums, no giant switch statement rotting inside a tick function.
It saved me a huge amount of time and effort. Turns out a decent chunk of those Unreal gigabytes is busy doing the work so I do not have to.
Anyway. Holidays soon.