Whenever I come back to AI I always wonder why use a custom AI Controller? Tutorials always do.
We have Character BP, Behavior Trees, and AI Controller. I could do everything in a Character BP. This is appealing because it’s all in one place. But I see advantage now in Behavior Trees for being able to visualize more complex AI. But adding an AI Controller into the mix seems unnecessary?
I’m using one Character BP (or children of it) for multiple characters, and I can just tell them to use different Trees, while using the default AI Controller. But maybe for example other people have separate character blueprints that share an AI controller? Maybe it’s just an organization preference? Or just the way people do it because it was in a tutorial?
Much of the Unreal design comes from having to scale up to large games.
You can put all the code you want to run in your program in a single file. As long as the program is small, that’s fine – it’s easy to know where everything lives!
But, at some point, your program becomes too big, and a single file becomes cumbersome. At that point, factoring out bits of the program into separate files, makes it more manageable.
And, at some point after that, you realize that there are bits you want to re-use, and then having separate classes for separate things means you can point the same class at several different target instances.
Specifically, “character” typically contains all the bits and pieces needed for some particular character – consider a MOBA, or character-RPG, where each character is highly stylized and has its own special behaviors in the world. Whatever is specific to presenting and animating a character, goes into the Character blueprint. Dangling hairdos, special attack FX, voice lines and mannerisms can all be Character-specific.
But a bunch of behavior is not specific to the character. For players, this “player, not character” behavior goes into the PlayerController. This means that the player can control different characters, without having to duplicate the player-specific bits (including “decoding the input commands” and “joining game servers” and so on.)
For non-players, the same kinds of behaviors that would go in a PlayerController, goes into an AIController. This means that you can build different characters, and have them all run the same AI behavior, perhaps with slight tweaks for things like “sensor range” and “aggressiveness” and so on.
Do you have to structure your game like this? No, not at all. The smaller in scope the game is, the less structure you need, because it’s easier to keep it all separate in your head anyway.