Feature Request / Bug Report: Optionally Unique Structs

I have been trying to build a project entirely using Blueprints, and as a result, I realize I wasted an entire evening trying to figure out why all of structs in an array were giving me same information when I had already added several “different” structs to array using a “make struct” node. Turns out, unless a struct variable value is different, it uses same struct reference when you assign struct as an entry in array. While I understand that having same struct in this fashion is efficient for engine, it can be a very clear annoyance when I have no Blueprint-node-method of copying a struct, and must instead begin attaching an integer ID to every struct I build just to be able to ensure it is actually a different struct reference.

It should really be considered a bug since it can’t be “fixed” in any way except to resort to C++ (I’m guessing. Haven’t actually tried it out) which is difficult for people who either can’t or don’t want to dip into that. I think we need either a “duplicate” node for structs (or variable references in general), or ability to add a property to “make struct” nodes that ensures we get a fresh reference.

Hi ,

I’m having some difficulty understanding your setup, and what’s not working about it.

If you make an array variable of a struct type, why would you expect that variable to take structs of different types? Or am I misunderstanding what you mean by that?

What do you mean about copying a struct? struct variable?

Can you post an image of setup that you’re using? A test project may also be helpful.


Wow, I have discovered that this problem is much larger than I initially thought.

I meant that contents of a struct end up dictating which reference struct is pulled from. So you can’t be sure which reference you are assigning values to when you call “set members” node. However, it appears problem runs even deeper.

Not only do struct references become same, but you can’t even set members of structs that are contained within arrays. Practically impossible to handle groups of structs…

Ah, I see now. We have a bug report already for issue with Set Members in Struct not working if struct is contained in an array (UE-6451). I’ll add your notes to that. I’m going to do a quick check to see if first issue you ran into is directly related or if it needs another bug report.

Hey ,

Thanks for additional information. It looks like struct array variables interpreting multiple structs as same if they have same values is possibly separate from other issue you found (Set Members in Struct not working if struct is contained in an array, UE-6451). I’ve created a new bug report for this issue (UE-18282), and I’ll let you know if I see any update on it. Thanks for report!

If that set members in struct bug were to be fixed, do you know whether or not that would show up in next 4.8 update, or whether we’d have to wait until 4.9? Also, do you know of any explicit workarounds for this given that I’ve already organized my content into arrays of structs…?

I haven’t gotten a chance to test it, so I’m wondering if maybe I can do following in Blueprints to get values I want:

struct3 (struct var) set to array1->get(0), set members from struct3 var, then re-assign struct3 into array1 via setArrayElem node. Want to be able to retrieve modified values from array index I assigned struct3 to later on.

Unfortunately I don’t have a timeline for when either will be fixed, but it definitely won’t make it into a 4.8 hotfix. Earliest would be next major release (4.9), but I can’t guarantee that.

As far as I know, there isn’t a workaround for struct/array problem. I’ll let you know if I find one.

I’m not sure how you’d make your suggested workaround for AddUnique bug work, but please let us know (with images, if possible) if you get it working. Otherwise, I like your method of adding an Integer value to identify each (and thus make them recognized as different by AddUnique node).

I was able to confirm that if you “get” a struct from an array, assign it to a separate struct var, set members from var, and then reassign that var into array index, you can generate an acceptable, albeit awkward, work-around.

Also, as part of “feature request” section of this, I’d like to be able to select when a struct (or any variable for that matter) is passed by copy or reference within Blueprints. Currently you have to hard code it, but some sort toggle-able / switch-able ability would be highly convenient for next release. Part of my headaches in figuring all this struct stuff out came from fact that I sometimes couldn’t identify which one it was, so things felt a little unclear…

You can already pass variables by reference within Blueprints using functions or macros. Is that what you mean? If you take a look at Details panel for function or macro, expand input and there’s a checkbox for Pass-by-Reference:


I never noticed that before!! Yes, that is EXACTLY what I meant. Thanks!

Is there no way to do same for output pins? I was wanting to create a “getter” function that provided original address of a struct so that I wouldn’t have to re-assign a struct var after using a “set members” node.

Object A houses an actual struct. Object B has another struct var. I assign B’s struct to be A’s struct (want this to be by reference). Modifications to struct in B should then be reflected in A. What are best methods you know of to handle this situation?

Illustration of options I’m aware of:

  1. A-MyStruct-GetNode → B-MyStruct-SetNode (by reference) : gotta make a custom function for this with a reference input?
  2. AStructContainer-GetNode (actor ref var) → B-MyContainer-Set (automatically by reference) : Have added task of retrieving A’s Struct within B’s Event Graph / functions.

Unfortunately no, there’s not output option for Pass-by-Reference. I think it normally wouldn’t make much sense, and while it might help get around this bug problem is bug and not that function outputs don’t have this option. I’ll check with BP team and see if it’s something they’d consider.

I think first option makes most sense to me. It requires an otherwise unnecessary function, but it’s cleanest option I can think of as a workaround.

Well, “bug” is that set members node of a struct from an array doesn’t work. What I’m thinking of is something different; namely, it is fact that I cannot directly grab address of a non-Actor variable unless it is passed to a function first.

As a developer, what I feel like I should be able to do with Blueprints is choose whether I want value or address of a variable any time I reference it with a Get or Set node.

most accessible version of this I can picture would be following:

  1. I can create a Get node that retrieves current value of a variable. I can change values associated with that variable freely (already implemented).
  2. I can create a Set Value node for any variable that fills its contents with that of plugged in variable’s value (already implemented).
  3. I can create a Set Reference node for any variable so that its contents are mapped to be same as contents of another variable. Any changes in one variable will be reflected in other variable.

Proof that using variables as references in and of themselves is not possible at moment:

Ah, okay. I’ve created a feature request for this, UE-18537. I’ll let you know if I see any movement on it. Thanks!