Problem with select node and arrays

Branch: Binary

Build version: 4.2.0-2092659

I think I found a bug with the Select node.

In my project I would need to fill one of two variables depending on context. So I use my two different variables, which are arrays, to feed the two inputs of the select node.

I took the problem out of my context and simplified it as much as possible. To the point that it is irrelevant to use as is in a real context, but it shows clearly what is wrong. Since an image is better than a thousand words:

This works as intended and spams 55 and 66 on the screen.

This does not work, the variable does not get updated and it spams zeroes on the screen.

Is it a bug, or am I missing something?

Howdy Grumzy,

Thank you for your bug report. Just wanted to ask a few more questions about your blueprint setup. In the ‘Debug Multi Use’ node, I imagine that you have 2 or more default values in the details of that node, correct? That was the only way that I was able to have the 55 and 66 appear on the screen in the first screenshot that you have provided.

Also, I believe the zeroes are showing up because the default values of that Debug int node are zeroes. If i changed the one of the default values to 1, I would see 1,0,1,0,1… I believe that the select node is directly referencing the default values of the int node and not the values that are plugged into the ‘Set Array Elem’.

If possible, could you try and change the default values of the ‘Debug Multi Use’ Node and let me know what your results are when you have when you have the select node hooked up?

Thanks and have a great day!

Thank you for your answer Sean.

You are right, in the default tab I have 2 default values, both containing a zero value. And yes, whatever these default values are, let’s say 8 and 9, they are the numbers that gets spammed on screen (8,9,8,9…). I will use the 8 and 9 default values for the following test.

That precisely describes the problem that the Select node does not work with the Set Array Elem node. My guess is that it compiles because every pins are compatible, but the Select node allows only data to move from left to right, and not from right to left (with the Set Array Elem), and I think it should.

… I believe that the select node is directly referencing the default values of the int node and not the values that are plugged into the ‘Set Array Elem’.

As a precision to that statement, the select node references the last values stored in the variable and not the defaults one.

Here is a more complete test:

As you can see, the final variable values are 11 and 22, and I would expect them to be 55 and 66.

Note that on this screenshot the Print String node is now fired directly from the variable and not from the Select node, but in both case I get the same unexpected result.

Hey Grumzy,

I was working with the Blueprint that you have shown and think I may be on to something. Have you tried changing the ‘Select’ Node to ‘Select Int’ instead?

The Select Int node only takes non-array as input/output, it would not take an array of Int.

Anyway, in my real project i would like to use the Select node to control arrays of a custom Structure i made. I used an array of Int in my examples only to simplify things, but the unexpected results are all the same.

Howdy Grumzy,

Sorry about the delay in response to your issue. I reached out to another Dev for some feedback on the issue and think that the issue may be that when the ‘Int’ variable is feeding directly into the ‘Select’ node, it is only getting the numbers from the ‘Int’ variable and not the ‘Set Array Elem’ item numbers. If you place the ‘Select node’ after the ‘Set Array Elem’, then the 55 and 66 numbers will be feed into 'Select". Here is the Blueprint I have set up:

Let me know if this helps out with your issue. Thanks and have a great day!

Hey Grumzy,

Just wanted to check in with you and see if my previous response helped to clear up the issue. If not, please let me know so that I may further investigate the issue.

Thanks!

Hi Sean,

I thank you for trying to help me work around the issue, but the point of this post was more reporting what I thought was a bug than seeking for alternatives. (English is not my first language, I hope this doesn’t sound rude). I can think of some ways to organize my code without the buggy “Select” / “Set Array Elem” combo. When I first wrote this report I didn’t have an elegant alternative, but since then I found a decent solution.

That said, I need to comment on your last code sample - It doesn’t allow the use of 2 or more array variables. I hope you realize that in the real situation I do not use the same array variable to feed the 2 (or more) entry pins of the “Select” node. In my previous code samples I simplified the example as much as possible to pinpoint and make it obvious what I think is wrong. It was a simplified demonstration, it was not a real life situation.

The real code I would like to use is more like this:

The bug is simply that you cannot set an array element through a “Select” node. I think this combination of node should work. Of course you guys can decide that it works as intended and I will be ok with that, but then at least there should be a warning when compiling this combo because as it is now, everything plugs correctly and everything compile, but it doesn’t return the expected result.

The solution I found:

Your explanation about “what is present at the output pin” makes sense with my observations. If I understand it right, the output pin of the “Select” node contains a copy of the data from the variable (array or not) but not the variable itself.

I realized just now that the problem I’m reporting here would also apply to any node that has an array as its output pin and that in many cases (or all of them except the “Select” node?) it would not make sense to allow modifications to it using the “Set Array Elem” node.

Then maybe the bug is that the “Target Array” pin of the “Set Array Elem” node should not be allowed to be plugged anywhere else than directly into a variable?

Once again, thank you for your time and have a nice day.

Howdy Grumyz,

Thank you for all your help with this issue. I have spoken to a couple other Developers and this is the correct behavior of of the ‘Select’ node. It is designed to pass the array contents, not the array variable. If any other information is needed, please feel free to let me know.

Thanks and have a great day!

I ran into this issue today as well. I have a whole bunch of selects with arrays, but I guess the way Ive been using them up till this point its been fine. Thats good to know though

I am getting this error (once i connect “Set array of…References” var and press compile)in 4.18.3. However note that nothing is visible in the blueprint editor.

If the intended function of the select node is what Gribbs described the please add some sort of warning cause i saw some REALLY odd behavior during game play.

Also once i tried to “Launch” the game the first time it crashed during compiling and the second one it was as if not the entire code was compiled… Same was in the “Editor” while playing. Parts of code didn’t execute (i was stepping through the code and even if more blueprints where still down the line it simply returned before executing. Also i breakpoints that should been called weren’t) .
Furthermore note that the location “File:D:\blahblah…” doesn’t exist in my computer. I have nothing related to the engine there. It’s an empty disk.

*the cropped line by the screenshot is "LogOutputDevice: Error: Ensure condition failed: DestinationExpression->AssociatedVarProperty [File:D:\Build++UE4+Release-4.18+Compile\Sync\Engine\Source\Editor\KismetCompiler\Private\KismetCompilerVMBackend.cpp] [Line: 1363]
"

It is designed to pass the array contents, not the array variable. If any other information is needed, please feel free to let me know.

That doesn’t make any sense, since you can’t get any of the contents without the array handle…

I also need to be able to select which array I get from…

I thought it would work to make a pure function and use a switch on enum to grab the correct array, but that did not work either. I have to check which array to use a lot, so it’s going to be a pain to hard code it in there every time I need to figure out which array to use…