I wanted to create a basic ability system. This was the workflow i tried to achieve:
- create a blueprint for the specific ability (like a fireball) with all the information regarding it (What to do when used, costs, etc.)
- add it to the character when appropriate
So far this is the only way i got it working:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Spells)
ATAbility* ability1;
In …Character.h . basically the Spellslot.
Then i created a class ATAbility. All my ability blueprints are childs of this class.
And this as TAbility.h:
UCLASS()
class ATAbility : public AUsableActor
{
GENERATED_UCLASS_BODY()
public:
[...]
UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = Ability)
bool Cast();
[...]
};
Now I can create an Ability with something like this (FireballAbility blueprint)
http://puu.sh/eneRT/a57e5c7378.png
But now I´m kinda stuck with some Problems:
- I have to spawn the Ability in the world (thats why it inherits from AUsableActor) … kinda sucks, but i could work with that
- Because it is a pointer to the object thats in the world, the Ability gets lost when I deload the level i spawned it in. And i have no clue how i would save my Character in a way that I could restore all the abilities after reloading.
Any ideas how i could circumvent my problems? Or maybe a good tutorial on something like this?
My last idea was to code all the Abilities of a characterclass in the characterblueprint, but that would be pretty meh.