Download

Need some guidance.

I’m making a game following a few tutorials and doing custom stuff as well. I got to the point where I’m pretty close of getting the base functionality done and can move to world/level building and in order to make it easier for myself I decided to tackle a semi procedural/semi modular approach to buildings. That is, dragging the building’s respective blueprint on my level, having it generate a random variant based on preset rules but then having the ability to switch out pieces manually.

Haven’t gotten far into it yet, I have the blueprint creating a cube with predetermined values and I have the option to specify the number of floors and number of tiles in each direction. Also I can set the pieces I want ie in a 3x3 tiled house to have the first tile on the left wall as a door, the second as a window and the third as a plain wall.

My problem is that due to the way I built it I have the above mentioned options duplicated on every floor, so everything is identical to the first floor. I tried setting up arrays so I have one that stores the floor numbers and one that stores the tiles for that floor, so by changing the first one I can specify the floor and with the second one I can tell my blueprint that I want this specific piece on that tile.The problem with that is that since everything runs on construction, I either resize/clear the arrays everytime the construction runs or I end up with a huge amount of array elements pretty fast because in every change I make the construction script runs again. If I resize/clear them I lose all changes (actually I’m never able to make any changes) because every time a change happens the construction runs again.

I also tried to make the generation blueprint a child of another blueprint and resize my arrays there, but the shader complexity was deep red and it scared me, plus I didn’t have access to the child’s variables anymore (I guess I can create those variables on parent and transfer the values, but I don’t like that way because of the shader complexity.)

Any ideas how I can resolve this and be able to keep the values of my arrays or another way to achieve what I want? (Being able to have access to every tile on every floor regardless of the blueprint destroying and reconstructing itself every time a change is made?)

I plan to have it run a few times to generate villages etc in a medieval setting. So like ~10 houses per village, or maybe if done having it generate the entire village so while it won’t be like making New York in the editor, I’d like to keep it lightweight if possible.

PS. I’m using ‘Add child actor component’ instead of ISM’s or HISM’s so I can have the tiles fully functional ie interactable doors/windows and so on. I know it’s not optimised but couldn’t find another way to do it…