Tips on populating and storing dynamic data for many AI controlled characters in a city builder game?

I’m making a city builder game as my first project in Unreal, and I guess I’m just trying to wrap my head around storing dynamic data for many unique characters (up to 100+). Each one will need unique attributes associated with them like name, occupation, residence location, and various dynamic stats and vitals.

I’m currently going down the path of using Structs and Data Tables for outlining defaults and assigning some of the core variables on the character class, but still need to understand how to bring it all together and implement it on a large scale in a way that will be dynamic and efficient.

–Would you expect all of the attributes to just be stored as simple variables on the BP_Worker character class, or perhaps within an Actor Component? Or is there an external repository I should be writing all of this too?

–Or should I consider looking into Data Assets for this, which I recently discovered?

–I’m also curious if I’d be best to use Enums to set some of the attributes such as Occupation and Gender, or if I should consider using Gameplay Tags for almost everything.

Most tutorials about storing stat data like this are just focused on a single player’s character, not many individually spawned NPCs with unique attributes. Curious if anybody has any suggested tutorials, reading material, or specific concepts I should look into.

your looking at the composition pattern.

using TMaps of GameplayTags and Structs(Instanced) and interfaces are a good idea.

for instance with attributes you can use TMap<GameplayTag/Float> then have an interface that returns the float by tag or 0 if tag not found.

for complex data i use FInstancedStruct, then create wrapper static functions. so use an interface GetPropertyByTag which returns an FInstancedStruct then the static function which converts/checks the FInnstacedStructs is valid and the correct struct type which will resolve it to your expected struct or return a default value if the property doesnt exist.

OR if the data isnt mutable you could just return a DataTableHandle to the Data but you’d still need to switch on Tag to convert to the expected DataTable Type

1 Like