Array add of scene component doesn't work

I’m trying to implement a tetris-like game, using static mesh scene components for the individual pieces.

I made a function that essentially takes in a “spawn template” (glorified bool array where true means there’s a block) and spawns them in, then what i want is to take all those spawned components into an array for later reference (e.g. to handle the “falling” of the blocks): weird array behaviour posted by anonymous | blueprintUE | PasteBin For Unreal Engine

This is where i’m running into a roadblock, for some reason my function is able to spawn them, and attach and position them correctly, but they never get added to the array (both FallingShape->ActualBlocks and the freshly made array when checked before making the struct are empty ( length==0), and the ArrayAdd itself returns 0, so it’s definitely an issue with ArrayAdd, not the struct).

i can SEE them on the screen at the correct position etc, so the whole spawning+setLocation stuff (which even happens AFTER the add) definitely worked, for some reason just the adding is completely (and silently, there’s no messages about it, even on a engine debug build) ignored.

i really have no clue what i might be doing wrong here, has anyone experienced a similar issue and might enlighten me?

EDIT: just tried using a struct with a single SC_Block reference inside, as a kind of “wrapper” to put into the array (just in case the array tried to be “smart” and failed to do some kind of by-value-copy), didn’t change anything, i can put the reference into the struct and get it back out no issue, but can’t store it in the array.

You can not use make array. You need a proper variable.

wait seriously? make array can really only make a const? ok didn’t know that (and as far as i read, neither did the docs), thanks, will try abusing a local variable asap (luckily i’m already splitting everything into neat functions, so i’m not gonna spam the object)…

tried it (just added a local SC_Block[] ActualBlocks and 2 get nodes for it instead of the edges that connected to the MakeArray before), works perfectly, thanks so much, i’d never have realized that.

does seem like a pretty big oversight tho tbh, i mean i can spawn actors, make vectors and any kinds of structs, instantiate whole widget hierarchies A-OK without using any variables (that’s what the edges between nodes are for after all), but a simple array is suddenly a problem? that just seems wrong. feels kinda like someone thought “hey we got functions that want a const [] parameter but always using a variable each time is a bit overkill, so lets make a function const auto[] MakeArray” without realizing omitting the const part could serve a purpose…

i mean i could literally make a <T>[] NewArray(){return /*local*/ <T>[];} with one local variable and a single function return node, kinda feels like that should be in the stdlib?

then again it’s probably easier to code by just inferring the type from element[0], so i see why they did it, but it seemed to “correctly” infer the type when hooking it up, guess that was just a UI thing.

If you don’t want to create variables you can create a macro in a macro library and use that instead.

nah making the variable feels way less hacky than making a whole new lib for this (and after all that’s what i would’ve done in C++ too, and even the way i tried before, just would’ve been an unnamed implicit one hidden inside the blue graph edge), it’s just a bit weird that this seems to be the only case where it’s explicitely required. feels like that macro you’ve shown should’ve been builtin to begin with.