Select node doing all cases at once?

Here’s an example and a log to demonstrate:


Is that me or select node is not branching the inputs but executing all them at once every time?
If I replace this to switch or branch - it will stop spamming this warning.

I mean this is something that everyone should know about this node. Because if there will be some complicated calculations (lets say 5-6 branches) instead of just one it will do all of them despite the condition. Which may seriously hurt your perfomance.

1 Like

Hey @FishMan!

Not sure what you’re getting at here, it’s not saying “Hey, I tried to divide by zero.” What it’s saying is “Hey, warning, there’s a Divide By Zero and that can cause a logic crash.”

Can you show what you mean by “If I replace it with a switch or a branch”? It’s likely that a select node has to have reference to every input as unlike a switch or branch it does not have an execution line due to it being a pure operation.

when is this being called?

if you are not in PIE the construction script runs many times any time you do anything with the actor in the level. Like if you move it the construction script will fire a bunch.

If you have it called from begin play and enter PIE it will only run once and the output associated with the index will be processed.

Yes select nodes evaluate each choice. Btw there’s a safe divide node.

1 Like

Exactly! And I mean this is logical since they are parameters for a pure function.

You just subconsciously perceive it as an analogue of “case” from C++ but in reality “case” is “switch” node, not “select” node.
“Select” node is a pure function with multiple parameters.

So it will evaluate all of the inputs before picking the answer.

So everyone should be aware about that and never hook any complicated math to this node.

Looks like there is a bug report for this that was recently reopened:
Unreal Engine Issues and Bug Tracker (UE-20044)

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.