Question regarding Structs, in particular can players select between various Structs?

The Goal: I want the user to be able to select a skeletal mesh from a list of skeletal mesh’s and add it to their character (like choosing different types of helmets for example). I’d also like each helmet to effect the players abilities in various ways, for example one helmet increases speed while another decreases speed but increases armor. I know how to do this assuming I can store unique integer data with each skeletal mesh.

I’ve been looking into structs and they appear to be what I need. Create a struct for each skeletal mesh helmet and include integer variables to manipulate character actors attributes. This changes the player from selecting a skeletal mesh into selecting a struct. But I am having trouble figuring how best to do that. Turning a struct into an array appears to give me a bunch of editable copies of the same struct where as I need an array of each unique pre-made struct themselves. I tried nesting the structs into a Struct of struct variables but for some reason the unique data of each struct doesn’t carry over to the nested struct of struct variables (all the data appears to need to be re-set in the nested struct despite that data being present in each unique struct).

I feel like I need some form of general struct array that houses all of my unique structs but I see no such general struct variable. Or am I going about this wrong to begin with? Any help is appreciated.


As you said…

Create a struct to define data you need.

Then create a DataTable of the struct.

During game, read datatable into array/map/or query directly

Thanks I looked into this and it solves the problem of being able to store multiple unique structs and calling them through the “Row” string but it doesn’t look like I can add rows to a data table during run time which I will need to be able to do. The inventory that the player has access to will need to be dynamic so unless I can add and remove Rows (Structs) from a data table I am not sure that will work.

How is this done for DLC type content for example? Say the game has 4 helmets stored on the Gameinstance but the player only has 2 helmets stored on their Playerstate (I assume that is where it would be stored). Then the player obtains a third helmet from the Gameinstance which moves it over to the Playerstate. I can do this no problem assuming only a single variable is being moved. But if each variable is really a Struct…how is this typically done? The data table is perfect but from what I read they aren’t writable so how do you add the new Struct from the Gameinstance datatable to the Playerstate datatable that they actually select from before a match?

If you want to modify at runtime, then store everything in TArray of the struct.

When an item is added to inventory, you can read it from the DataTable and copy it into the inventory.

I can’t use the “Add” node to add a struct to an array of distinct structs the way I do other variables though can I? I thought Tarray could only hold one data type. I understand how to pull a specific struct out of a data-table of distinct structs. But I don’t understand how to move the distinct structs themselves between arrays/datatables or other structs. The arrays don’t seem to be of much use because they either only hold one data type or hold multiple copies of one struct but not multiple distinct structs (the way a data table does through rows). In other words Im not grasping what cataloging and/or travel method to use to hold and update a dynamic “Inventory” of distinct structs. Appreciate the help though Ill figure it out

The create an array of type YourStruct.

Appreciate the help. I’ve ended up just storing a struct in a blueprint class, created an array out of the blueprint class and then can select through it’s children effectively selecting through distinct structs.