Get a variable by a string?

I am trying to make an array of arrays to make a table. (I couldn’t find anything to make an editable table if you know something pleeeeeease let me know)

I am trying to loop through all my arrays (height0, height1, height2, …) but I cant find any function to get an array based on a string.

In my blueprints I loop thought and append the index to string “height”. I want to call the variable by that string, I don’t know if there is a better way.

you can try looking into Data Tables.

also if you got to the marketplace tab then click on Free then on Free for this month you will find an assets that let’s you work with MySql if this is something you need for your project

1 Like

definitely datatables are good to work with if you want a table :slight_smile:

1 Like

Hi there,

I believe you want something like this.

TArray<TArray is not supported. A Datatable is not editable, it is read only. Getting a value by a “Key” such as a string is done with a TMap container.


Unfortunately I do not believe what you are trying to do is possible using blueprints. You cannot access a variable using a string. You need a reference to that variable. I have two possible workarounds for you to try though:

1.) Make a structure containing an array of ints. In your bp, create an array of those structures. This used to not work, but the bug report is marked as “could not reproduce” so it may work now. (UE-11171)

2.) Combine your arrays into a single array and use indexes to mark boundaries.

You can only map a key to a single value, so this wouldn’t really help.

Map a key to a struct and Bob’s your uncle.


Create a struct that only contains an array of your desired class (in this case I used Actor)

Create a Map with String as Key and your struct as value

When you add a value to the map if the name already exists it gets replaced

To read all the values from the map you can iterate through all keys and use the find function:

that is OK , same way we do it in c++ when TArray nesting is not supported. Just a struct wrapper.

unreal has already a way to access data using text as input.

You can do this using Primary Data Assets, which are accessed by passing a “link”, “string” with the location of particular data asset located in the packed game data. You can then for example construct this link using strings.

This may not be what the topic of this thread is requesting, but just so people reading this may be aware of this option

1 Like