Populate Array of Enums

Hi there,

i’m facing a small issue because i’m new to the engine :(,…

… basically i want to populate an array called “Faction Array” with an Enum type and give each Enum at each index of that array a different value of the Enum ,i mean choose a different name from the Enum 3 name choices which are “Darkpiece” , "BrightPiece "and "EmptyField " shown in picture below :slight_smile: …,…

… and I want the array of this type Enum to hold the Enum value set to “DarkPiece” from index 1 up to index 15 of this array , and to hold “EmptyField” value from index 16 up to index 47 , and to hold “BrightPiece” value from index 48 to index 63 … cause my array length is 64 .

in picture below i’m trying but with no result …So anyone knows how to achieve that or is it even possible !! …???:D…

Thank you for your support , appreciated :).

There are quite some options to do that:

1-Structs which is basically a group of different types) to form a new one and you can create a vector from this (easiest)
2-Create data tables to be static filled and you can use a spreadsheet (like Excel) to populate it and save that info (needs a bit more knowledge but not much difficult)
3-Database object from Marketplace assets (more complicated if you are new to engine)

I hope from this you can find your way out!

Hi NilsonLima,

thanks for your response very helpful information ,

though i don’t know how structs could help here cause i’m only filling an array of enums with enum values there is no different data here , …

… but someone point to me that what i did in the picture above is right exept the resize array to 64 i get rid of it and it works , that’s true i’m all set now besides that there is cleaner ways of doing it to avoid the repeating branches i did .

here we go the cleaner version using set array elem in picture below …

Now it makes sense what you want to do… thou it is not clear why you need those values in an array. Sometimes would help a lot knowing what you plan to do… there are several ways to crack an egg :slight_smile: Good you got it figured out!

Just to let you know all i was doing this for is to set factions for chess pieces ,…

… so" emptyfield" faction means there is no piece then the “darkpiece” and “brightpiece” factions are for each player chess piece color , so it’s a dynamic array which i set it to be updated with the piece factions whenever the players move a piece on the chess board ,…

… i did it this way cause i can’t set the faction on each piece since the pieces are just components added on the fly in construction script , it would be easier if each type piece was an actor so i can set the faction in its blueprint , …

here is the construction script of the chess board blueprint actor , so everything is done here there is no other blueprints that’s why i needed some sort of faction indicator … the array factions i discussed in this topic comes as the next step after adding the components here …

Note : if you see the picture below just ignore the alpha numeric script in Comment box at the top of the picture that was another dumb thing i did …hhh…:smiley: