If iam filling in some data in the editor in the details panel of the coresponding blueprint, all is working well.
But if iam trying to create the GridArray per blueprint, the result is somewhat wierd.
The creation process does resetting the grid and generating the floors, but nothing more.
In this test scenary, iam generating 2 floors, so:
The GridArrayMaster only consists of Index 0,1 (without any content).
If I remember correctly - I had a similar, if not the same, problem. Strangely enough, iterating through Structs using a ForEach loop does not seem to work. This link (to the UE AnswerHub) shows the issue I was having, which sounds similar to yours, and documents a workaround.
If this is not what you are experiencing, could you elaborate on what the difference is? Also, what is your engine version? I think this might have been fixed in 4.9, but am unsure.
Indeed. Iterating through this seems to be the problem. But only for writing!
Reading the actual iterated element of the array is no problem and currently working (following picture).
The next picture is showing a gap of the whole array (in editor).
hmm⌠iam not pretty shure how the âbreakâ Command for a struct works. Iam having a feeling, that this is my problem.
Iam breaking off the whole array iterativly, but never use the âmakeâ command, to put everthing together again.
But i have no idea how to include the âmakeâ command.
Your images are teeny tiny so I cant really say for sure whats going on.
But I am 99% sure that your problem is the same thing I ran into. When you do âgetâ on a struct from an array, it returns âBy Valueâ , not âBy Referenceâ. So you are manipulating setting on a copy.
There are plans to fix this in code at some point but the plans are not concrete yet.
For now I have a workaround which is to recreate a new Temp array, and add each of the things you want to set into this array one by one. Then after the loop is done doing that for everything, you can do âsetâ on either the entire outer, or whole array depending on case. It is a bit of a pain but it is the only workaround I know for now. If this is sounding very confusing, I can try to dig up an example image.
The bottom red comment box does not work, since the âstructâ reference from the âGetâ is actually a value not a reference. It is very misleading though because the âstruct refâ pin even has the âby-refâ diamond shape. But for that to work, a reference needs to be connected as well.
In this case I just re-make the whole struct element and do âset elementâ individually. If you need to do this nested, you may need to rebuild the entire sub array first using a temp array as I said above.
Thanks for your answer. That sounds like it is the reason of my problem.
But i cant click on your Attachment (âInvalid Attachment specified. If you followed a valid link, please notify the administratorâ).
Hmm⌠iam using âgetâ on an array filled with structs. After that iam using âbreakâ on the âarray elementâ pin of a foreachloop. I can only imagine that the loop uses âgetâ in background too.
So in the blueprint where I want to break the original structure variable (from an array of structures which I get with foreachloops) to extract information, I need to create a new identical structure array variable and apply all the entries from the original one to this new one before breaking the new one? Or am I way off?
Or was using the make command the solution you used in the end? How did you set it up?
Hmmm⌠i tried to get both in one screenshot. Remember that iam creating a tile based game, so that my comments are related to that!
First, iam breaking through every element of the array (âGet through the GridArray incrementallyâ).
After that, i recreate each element, beginning with the tinyiest (âRecreate Y-Axisâ).
Every recreated element will get stored in an temporary array (eg. âTemp2D-y-axisâ).
These Temp. Data is the basis for the elements of the next step (eg. âRecrete x-axisâ).
Just repeate the steps, till the last stage, where alle the temp arrays get the content of the original array (ârecreate floorsâ).
With those steps, i have broken down through the whole array and did recreated it completely WITHOUT altering any element, but this will be next:
The upper comment box (âCheck if actual tile is the searched oneâ) will look for the element, what will be altered.
If the position is reached, the normal recreation process will be ignored for this step and an alternative one is used (âalter tile with fiven informationâ).
Glad i can help
Something got cut up:
At Input: âNEW Tile Definitionâ
And on the right side; the âset array elemâ is the last used function (Compare with ârecreate floorsâ eg). There is nothing more.
PS: The images are in FullHD Scale. So either download them or open them in a new window, to watch them at full size