Array of Objects in Blueprints

Hey guys,
Iam currently working on a Blueprint for a room dimmer system.
Iam pretty much finished, but my solution is pretty big and repetetive.

This is what a single dimming-element Blueprint part looks like:

This is what it looks like in video:

Then I discovered there is an “For Each”-Node and also a “Make Array”-Node in the Blueprint System. I tried to make an Array out of my dimmer-elements, but it is throwing an error.

I think with the For-Each Loop I can save alot of other Nodes and reduce my system to minimal state.

Each of my dimmer elements waits a specified delay-time before it starts. Thats why this Blueprint got that complicated.

This is my current state on the “Array solution” (I only added 4 dimmer elements for test purpose)

This is the error of the “Make Array Node”:

Is there any way to solve this problem? To Make an iterable Array out of Objects?

Greetings and sorry for my bad English

your ForEachLoop node needs to be executed, connect an event or level start node to it. That should fix it.

Still same error. :frowning:

delete the make array node and do it again. sometimes it works for me.

Lol, that fixed it! Thx man :smiley:

yeah, there is an issue with some nodes. They don’t refresh themselves when you correct an error.

glad that fixed it.

I assume you dont have a 3d tool in which you can animate these blinds?
It would be much easier to make a simple animation in max without the need of all these repetitive blueprints.

Check out the Array demo in my notes on googledocs : I added to the doc, on p. 34 a guide on using Arrays, which is a bit like using Object Lists in Kismet. The example shows toggling a bunch of lights all at once from one switch. Pretty easy, and there’s probably other ways to do that but I just wanted to see what the array functions are.

I don’t use the For Each loop … though that’s saving a lot of work I guess and I should do it.
I use “Last Index” and “Get” then do some action then use “Remove”, and loop that until the Index of the array == 0 (remembering index 0 is the first item in the array).

Thanks for your answers. I dont want to use predefined animations, because I later want to enable alot of settings in the construction graph, like degree of turning.

I really would like to solve this with a for each loop, because I really used it alot in programming and its kinda familiar.

So I could remove the error from the “Make Array” Node by simply recompiling some times. But when I execute it, my blinds dont rotate, even the timeline and rotation nodes are all the same as in my working blueprint (the huge one).

Maybe I plugged some wires in the wrong place. Do you see any mistakes I did?

The Loop gets triggered by an Input event, which works fine and also without the delay Node it doesnt work.

Probably because without the delay it is trying to fire all of the loopbody outputs at the same time and play all the timelines at the same time.
i am not sure what the individual array elements are or how this is supposed to look which makes debugging the intended behavior tricky. Is this supposed to fade all4 things at once, one after another or what?

Looking again, you are telling to rotation node to look at a different actor the very next tick. So there is almost no time for it to act.

The Objects “1”,“2”,“3” and “4” are all the same object. A simple dimmer Element of the dimming system (you can see it in action in the video).

So in this for each loop I try to turn every single dimmer element 90 degrees. But every element has to wait a specified delay time before it starts rotating to get that effect you can see in the video. So it is suppossed to turn all 4 things one after another defined by the delay time. This “one after another” thing is the reason I want to solve it with an for each loop.

Is there any way to tell the loop when the loop body starts and when it ends? I think this is currently the problem of my system.

Even if they are the same actor but different elements of the system, you are still changing the element instantly without the delay by having the Rotation node fires off update. I think having the delay be the length of your timeline is the way to go in this case. If you want them to all play at the same time you will need 4 separate timelines and 4 separate rotate nodes.

Thank you for your response!

I just tested this, but had the same results as before.

I kinda have the feeling that the “For-Each”-Loop (in the current state) isnt made for this kind of stuff. In programming you could define a begin and end of the loop body, but it seems like its not working out here.

Also very strange:

Even if I only connect a single dimmer Element with the “Make-Array”-Node and then start the for each loop, it wont rotate the Object. It fires that timeline, and this interacts with the “Set World Rotation”-Node, but it seems the “Set World Rotation”-Node doenst know which object to interact with. But It is connected with “Array Element” as the target. Shouldn’t the Array Element represent the current Array being processed by the “For-Each” Loop?.

But If I connect for example element “1” directly with the world rotation and leaf the other stuff as you can see in my screenshoot, it will properly rotate that connected element. But this wont help me because I wont to rotate more than one object (with Delay inbetween).

If you are having a trouble with “for each” or just doubting its behavior, you can easily do the loop manually. Just make the array, get the length of the array, use a regular “ForLoop” node and set the length of the array to be the last index. Then on each loopbody, you “get” from the array using the loop current index pin to get the current item from the array.

Sorry you are having trouble with this. Maybe even with just 1 thing in the array, the foreach node was firing twice for some strange reason…

I think maybe make 1 blade blueprint handling the rotation with a interface that handles event or whatever trigger the start of timeline animation.
Then in the actual dimmer blueprint you get put up a series of “blade” asset as component, and call their interface function to make them start turning in sequence, and then make a public function of this dimmer blueprint.
Then in your level you put that dimmer asset to scene and have some switch trigger to call the dimmer rotate function.

Ok thank for your response. Iam going to try this in the next days. I will also give the foor-loop Solution a try, but I think that will deliver the same result.
Thank you all for your help, at lest I now know some more ways to modell stuff :slight_smile:

Duuuude… Macros!