Select nodes vs Branch nodes

Do you use Select nodes often? I like the idea, but the fact that they execute every input no matter what is scaring me off, especially when there are some more complex pure getter functions connected or when they’re inside loops with many iterations… Then I usually change them to Branch nodes.

I wonder if it would be possible to improve the Select node so it won’t execute every input. If so, maybe it would be a good idea to post a feature request for that. But I’m afraid that this is just the way the pure functions & function inputs work in Blueprints…

I must admit i still have no idea what the select node does or why you would use it. Actually i thought you feed it an index as an int and it would return the selection you picked (Like if you have 3 select options “red, Blue, green” and you feed it zero as the index it would return “red”). Your example completely confused me i must admit.

What i recently used quite often instead of Branch was “Switch on int”. So in my game if the user selects one option from quite a lot of options i save it into an int reflecting the options and then switch on that int to execute the code for the option. A bit more elegant than a hundred of branches that check “Int equals 5”, “int equals 6” and so on.

Yes, Select nodes can also use integer value, so then you can choose between many options, like your “red, blue, green” example. It can also operate on boolean value - so in this case, if boolean is TRUE, it will pick value from input A. If it’s FALSE, then it will pick value from input B.

Hmmm, interestig, i did not know that. But for boolean i think it does not have any advantage over Branch if i understood it correctly. I think most of it’s use would be to translate an integer (index) to a value.If i have to construct a usage example i might use one day then maybe to store a big number of greetings for a character according to his mood level. Like say 0 is the worst mood, being very angry and 10 is the best mood being very happy that function could select a greeting based on mood. Lets say mood is 0 it would return an angry greeting like “Ah you again, i was hoping you were dead”. Mood 5 is neutral like “Ah hello there” and mood 10 like “oh my best friend! How pleasing to see you”.

To me that node (from what i know now) is a translator from an index (integer) to some other stored value(A string maybe). But yeah the node definitely lacks a good description and examples. I think in the UE4 flow control documentation it wasn’t even mentioned.

Are you certain select executes every pin every time?

Bash me if I’m wrong but it should only return the item according to the index - or in the case of the above example either 2 or 4 according to the boolean value.

@Fronzelneekburm Select node should be fine when we input some pre-calculated values. But sometimes we need to calculate different values dynamically, e.g. inside a loop, based on current iteration. Then calculations for every input option is executed, even if only one is actually used. That’s why I have these concerns about the Select node.

@ In my little test case, the pure ‘Function’ function has a Print String node inside. It prints only once in the Branch node case, it prints twice in the Select node case. It’s probably one of the easiest methods to check that.

1 Like

Oh, so I see that I’m not the only one with these concerns… Short circuiting would be a good solution… Since we don’t have it yet, then as you say, probably just using Branches is the way to go for now. Thanks for the info.

I would also like this. SELECT often makes the graph much simpler, and can be useful in macros without execution input, so it is unfortunate if it does not true branching.

I just experienced this in a simple function for getting the parent actor’s transform. If there is no parent, that branch will yield and error, which it seems cannot be guarded against by the select condition:

True branching should be doable in select if they put the work in. In theory upon hitting a select mode, execute the selector before the options and only execute the selected option and it should be the same speed.

Aye, one would think it would be so simple. The actual practice is that it’d take the effort of about an entirely new feature to BP - such as this- to actually fix short circuiting. It’d be a great feature for sure, but do consider that what seems easy is actually very complex under the hood.

I stumbled over that. How do you add “Print String node” in something "pure "? You have no execution pins in pure macros or functions to plugin them into the print. An advise would be great. Thanks a lot.

Edit: I see now that pure function have also execution pins. Is on Macros also possible to have “pure” macros but print text? I wanted to make some pure macros, but when something failed, as example a pure cast, I ant to print something. Seems to be not possible to print something in a pure macro. Or how to solve it?

Yes, pure functions can have execution pins inside. I’m not sure about macros though, I rarely used them.