Unable to change the data within a struct stored in an array

Hi, I have an issue with trying to change the data of a struct stored within an array. Basically I have two structs: Struct_Main and Struct_Sub. Struct_Main contains an int and Struct_Sub, while Struct_Sub contains only an int.

Now at begin play event, I’m creating an array of Struct_Main consisting of two elements. Each of these Struct_Mains contain an array of 4 Struct_Sub elements.

Now I’m trying to change one of the Struct_Sub data when I press ‘P’.

I have a print string down the line as you see, to check if the value has been changed or not. But it always retains the original value that was set at begin play. I know that I can change any array element if I’m using the same method for a normal int array. But in this situation it always fails to set the new data.

It doesn’t work when you wire it intuitively for some reason.

You need to create an auxiliary array (for example structsub_temp), set it to structsub, set its element to the new integer then use it to set the array element of the struct main. It’s a bit complicated but it works.

Thanks, I’ve tried using a structsub_temparray and setting it’s element, but even this doesn’t work.

I think I might have to go one more layer deep and create a new struct from scratch to replace it. But honestly, not having this as a direct feature is kind of an inconvenience.

Thanks a lot, alperenakyuz. It worked finally. :smiley:

I had also made a mistake of not clearing out the struct_subarray after for loop during the initialization process.

Cheers, glad to help. Good luck with the rest of your project.