In Chapter 3, Exploration and Combat, we created a character class info for learned abilities, which was done in FCharacterClassInfo.h
, which is an array used to hold an array of abilities for each character that inherits a class. We need to extend this array so that it is adopted by any game character to hold abilities that they learn throughout the game. To do this, open GameCharacter.h
by navigating to Source | RPG. In class RPG_API UGameCharacter : public UObject
, add a public UPROPERTY
to learned abilities and allow it to be editable anywhere:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = CharacterInfo) TArray<FString> LearnedAbilities;
Next, open GameCharacter.cpp
located in the same folder, and set LearnedAbilities
to be equal to LearnedAbilities
from the class info that we created the variable in:
character->LearnedAbilities = character->ClassInfo->LearnedAbilities;
This will allow each instance of a party member to hold its own...