Stage 2 · Lesson 7 of 8
State machines
A treats an object as being in exactly one state at a time, such as idle, running, jumping, attacking or hurt. It also sets clear rules for moving from one state to another. This replaces a tangle of (true or false flags) like isJumping and isAttacking, which allow impossible combinations.
Start with an (a fixed list of named options) and a switch or match statement. Once the states grow, move to one class or node per state. Player controllers, enemy AI, menus and match flow all use state machines. Your engine's animation system is one too.
Common trapadding a new boolean for each new behaviour until the player can attack while dead or jump while in a menu.
A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock
Resources for this stage
Start with· follow one of these
- CourseFreeUnreal Engine Learning (Epic Developer Community)
Epic Games
Epic's free courses: Your First Hour and Your First Game teach the editor and Blueprints
- CourseFreeLearnCpp.com
LearnCpp.com · Beginner
Free, thorough modern C++, so Unreal C++ is only new macros, not a new language
Practise
Keep handy
Also worth your time
How Unreal C++ differs from standard C++ and how it fits with Blueprints
- Game Programming PatternsGo deeper
Free book on the state, observer, component and other patterns games rely on