Representing a list of characters and skills via Blueprints

Hello,

I’m looking for a way of making a “data blueprint” that would contain all game characters and their skills. Each character would have a name and varying amount of skills (each skill has a skill name, cost, and level they are acquired at).

In Unity I probably would have done this way:

var Character				= new List.<CharacterData>();
class CharacterData {
	var id 				: String;
	var skill				= new List.<SkillData>();
	class SkillData {
		var name			: String;
		var acquired		= new List.<int>();
		var cost			= new List.<int>();
	}
}

You can do something like this using a Structure. Right click your content browser and go to Blueprints then Structure. (the blueprints at the bottom part of the context menu) Here you can add other classes like characters as well as skills. The struct can then be added to any other blueprint you wish as a variable.

Alternatively you can create a struct for the skills information and attach it to the characters them self as an array.

21280-struct.png

Thank you! That’s exactly what I was looking for :slight_smile:

translating that Unity code into UE4 C++, would look like this:

// inside the .h

USTRUCT(BlueprintType)
struct FSkillData
{
	GENERATED_USTRUCT_BODY()
	
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Skills")
	FString Name;
		
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Skills")
	TArray<uint8> acquired;
	
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Skills")
	TArray<int32> cost;

};


USTRUCT(BlueprintType)
struct FCharacterData
{
	GENERATED_USTRUCT_BODY()
	
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Skills")
	FString ID;
		
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Skills")
	TArray<struct FSkillData> Skill;

};

//inside the class definition:

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Skills")
	TArray<FCharacterData> CharacterData;
	
	
	
//example of access inside the Cpp file:

FString PlayerName = CharacterData.skill.name;