Set Array Elem for structs doesn't work; what are the alternatives ?

In my case, I have struct that contains an array of structs, which contains another array of structs, which, regardless of what I do, can’t be filled. They are always empty. The array knows it’s size and the structs are always as default.

I need to save this data, and I can’t do it by any other way than what I am doing right now, how can I possibly do that ?

Bonus glitch : I modified a default value on one of my structs, and now the parent struct doesn’t recognize the modified struct.

EDIT : All of the above is wrong, the reason for that is because I was using Set Array Elem. You need to use SetMemberInStruct or reconstruct the array from scratch for it to work.

I recently tried to make same but in c++, I got an error about nested loops inside structs not being supported, I used Map for it, dunno about blueprint support of them in that exact case, but it should be working.

So, I forgot that structs arrays can’t use the Set array elem node, so that explains why.

They can now, you can get element by reference.

yeah, but the Set Array elem still doesn’t work and it’s much more user-friendly imo.

I’ve been using arrays of deeply nested structs (7 layers or so ) and it works fine; are you using *SetMembersInStruct *node?:

Wrapping everything in functions and spitting out ready structs helps tremendously with spaghetti management.

Some more info in this post: https://forums.unrealengine.com/deve…472#post845472

Also, there used to be a difference between a CustomEvent and a Function passing arrays of struct where the Event refused to pass a struct reference and always returned a copy. Not sure if this still holds true.

edit: you, of course, need to connect *ArrayIndex *of *ForEachLoop *with *SetArrayElem’s *index. My bad.

I remember reading that BP function input always pass a value, reference is just dirty hack connecting original data and all set nodes.

I’m using that now, but your SetArrayElem does absolutely nothing in that case.

Not sure how to respond to this other than by saying that this does work. Just try and see for yourself:

The array prints out updated text.

Consider posting your setup, it will be easier for people to help you out.

I actually don’t use Set Members in Struct or Set Array Elem anymore, I construct the array from scratch every time I use it, because it suits my needs better.

But try to disconnect Set Array Elem and you’ll still see “update this text!”.
Disconnect Set Members in Common Data and it’ll stay as before.

No, it will not update, why would it? Not sure why you’re saying this. You clearly have not tested this, have you? :p:

Updating as I’ve shown above works, so will constructing from scratch. Updating will be more preferable since you do not need to recreate the entire struct. And that’s quite important when you deal with multiple layers of nested structs, especially when they contain additional arrays of other struts.

Using the method of recreating structs from scratch on anything moderately complex will require a silly amount of unnecessary rewiring.

However, since recreating the entire struct suits your needs better, can we consider the original issue resolved?

Just noticed you’ve updated your original post. Glad you have it working.

set members in struct has no other pin than struct ref
wtf ???

Select it and expose stuff that you need in the details panel - that’s the best feature, actually…

1 Like