Best bp-exposed skill tree solution?

Hi guys,

I am interested in programming a skill tree system, which will be exposed to blueprints. My skill tree will have different nodes, that may have child nodes etc, just like skill tree system in e.g. Borderlands 2 or Diablo 2. As far as I see it, I should use graphs (though, there are many things I don’t need in graphs theory, e.g. fast traversal algorithms etc. I only need to store several skills and have hierarchy of their connections) or similar data structures for this purpose. The best thing would be to utilize the Behavior Tree editor, as it already has a tree-like editing workflow (it would be far more visually appealing then creating new skill nodes through blueprint or cpp code). Has anyone done such thing, and do you have any ideas for relatively fast solution? For now I am just thinking to create custom Behavior tree and, ignoring it’s primary purpose, store there my skills data :slight_smile:

You are over thinking the problem ;).

Let’s decompose it to basics.

Skill in tree is either object or data struct. You will probably settle with object. You want each skill in tree to do something. Skills doesn’t need replication (they really should only be executed on server if you need networking).
So create class like:

USkill

Or

UEffect

As skill is essentially just effect, which is attached to character, which listen for incoming events/delegates from other objects, and modify incoming properties of objects and send them back.

If you don’t want to expose skills back to blueprint, you can use raw C++ and function pointers to accomplish this functionality, although I don’t think it’s worth it, as you cut off one of the more important functionality.

If you are not sure, what I’m talking about you can check my code here:

You are going to be interested in AREffectType and ARAttributeBaseComponent, there are also some blueprints, which implements some testing functionality.
Code might work, or not for you. If you run it and will crash it is probably because of gameplay tags. You will need to reimport GameTags.csv

How you represent the skill tree visually, is just whole different topic.
I would probably create USTRUCT() which would contain few properties like:

CurrentSkill - skill in that particular node.
RequiredSkill - skill which is required to make this node active (the one higher in hierarchy)
ChildSkill - skill which is down in hierarchy, directly dependent on this skill.

The you just need to draw skill, tree based on this data.
Or you can just screw it entirely and draw it manually. Whichever works for you.

1 Like