Download

Need some advice on building an ability system in blueprints

Lemme just preface this by saying I’m a character artist, not a software developer… so please bear with me here…

I’m trying to create a single player game that has a lot of abilities that all have their own custom logic. I’m trying to figure out:

  1. Where to put all the logic for each ability
  2. How to execute the logic associated with each ability

Unfortunately the solutions I’ve come up with myself aren’t very satisfying:

  1. Shove it all in one giant monolithic blueprint (probably the character blueprint), a custom event for each ability
  2. Hook the attack button up to an enormous enum switch with every ability in the game in it, that executes the appropriate event according to the enum input

I feel like this would work, but is a really shitty way to handle this. I’m not even sure that doing a huge switch on enum every time I use an ability is even going to be performant.

Any advice on a better way to approach this would be greatly appreciated.

I would recommend building the foundation as an actor component. Build a good portion of the logic as a parent. Then, build each ability as a child of that component. The parent will contain commonly used logic, the children contain specifics such as numbers (damage, healing, armor added, etc), visuals (emitters), sounds, etc.

The goal is that to add an ability, you create a new child and simply plug in specific numbers and other variables to achieve the desired effect. The parent already contains the logic necessary to make the configuration fairly easy and quick.

At that point, all you need to do is add the specific spells to your character. This can be at runtime or in the editor.

Thanks so much man, I did some quick testing and I think this will work perfectly for what I need!

Components are the purist way to add abilities to a wide number of Actors at any time. But its still worth looking at other options, including what’s done in practice when you break apart existing Marketplace products or Community-Tools RPG examples etc. For example, if a Component needs to call back into a Character to affect changes, how are those comms actually setup and are they easy to maintain…

The code needs to be updated over a long time-frame, so you want the best solution which is often the simplest. For instance, if only half the characters will ever need certain abilities, maybe its just easier to use Inheritance. Also, what if some abilities are more geared towards enhancements like ‘special vision’ etc and don’t impact on a players health or something else. Is it better / easier to just use separate isolated BP-Child-Actors…

Sometimes just adding a few extra Structs / Arrays will get you by, rather than needing to do too much extra plumbing. Especially as you can separate code off into a new graph area anyway (whenever Blueprints become too unwieldy). Just a few possibilities…