Beat'em'up AI: How to store different attack types

Hi,

I’m still experimenting and trying to find some best practices for UE5. So this might be an question with an obvious answer :slight_smile:

I’m trying to create a simple AI for an enemy with a wide range of attack options (think beat’em’up-games) and I’m a little lost on how to store them/set them up to keep everyting clean and easy to maintain. So lets say I’m having 10 different attacks, all attached with some kind of constraints (e.g max distance to opponent, “mana” needed, status of opponent etc.). I want to build a system that somehow scores them and than selects and executes the best attack. That part I know how to do - but before I can do that: what would be the best way to store those attack-type information in UE5? Is there a type of datatable I could use that can be easily accessed? Should I create a single Blueprint for each attack (if so, of what type)? Or one base Blueprint and each attack as a child? Or something completely different?

I would need reasonably quick access to regularly score what attack would be the best in a changing situation and be able to use that data with different components (e.g my AI-tree would need access to the score, my character would need access for which animation to play…)

I know this is a somewhat broad questions, but all tutorials I find just somewhat gloss over it, just putting the one or two attacks somewhere directly into the BehaviourTree or in the Character-Blueprint. But I think that will get very messy fast.

I just haven’t figured out a good way to store such kind of “imaterial” data in UE5. But I’m sure there has to be one :slight_smile:

Just create Functions or each of your attacks. Functions are stored separately from your main blueprints and you can access them any time by calling them.

Thank you for your answer. But wouldn’t that lead to a lot of redundant code? Because the logic for each attack would be more or less the same with only the animation and stats-values changing.

That depends how you implement it. If the code is short, a bit of redundancy it wont hurt, but if you think its a lot, you can create a function that makes the ‘shared’ code part and call it within each separate attack function. Or you could create custom Events for the Attacks and functions for the shared bits of code.