Download

Blueprint execution flow not working as expected

Hi guys, I’m trying to make sense of a configuration of nodes that I just created while trying to understand execution flow in blueprints.

The documentation clearly states that data nodes (the ones without execution pins) will be evaluated once per every node that they’re connected to (https://docs.unrealengine.com/en-US/…ing/index.html):

Now, for the following graph:

Given the documentation quote, it would be safe to assume that the call to “Random Integer” should be executed 3 times, therefore generating 3 distinct random numbers (not always but you know what I mean), since it’s connected to 3 nodes, but it seems to execute only once and deliver that same value to all the connected nodes, which clearly violates the statement describing the node execution flow.

Is there any piece of documentation that clearly explains step by step the order of execution in the blueprints flow (a description of the algorithm as to say), that can help me make sense of how to place my nodes ( ideally with the performance perspective in mind)? Thank you in advance.

Kind regards

I don’t think adding counts as “executing”, only the Print String.

It appears that pure nodes gets executed once per node per execution pin and not per output connection so the explanation is misleading.
This means that if you want 3 random numbers you need to have 3 individual Random Integer nodes.

Thank you @mlindborg, @GarnerP57, so if I understood correctly, what you mean is that the quote above should be saying: “…(pure nodes) reevaluate their outputs every time an impure node connected to their outputs executes.”, therefore each impure node keeps some sort of execution scope, for each execution, for all the nodes connected to their inputs.

Your assumption is correct, it is calling the random node several times and getting different results, I think you’re misinterpreting your code.

This example doesn’t really matter so much, but when, for instance, you return more than one argument from a function and then call that function on tick. You might start wondering why you’re getting some very weird results ( and a performance hit, if the function is complex ).

If it was only called once, how come the graph below generates odd numbers?


( like 15, for instance ).

Thank you for your response @ClockworkOcean. I have executed my graph multiple times (more than I’m proud of), and I can confirm that absolutely every time, all the add nodes received the same number, and therefore must have been run/generated only once, which I couldn’t initially comprehend since I must have misunderstood the execution flow description in the documentation. I reckon that your example can easily produce a 15 for example if the Random result is 7, since the first add node is adding one to the generated random (7) therefore spitting out an 8, which when passed to the second add, and have 7 added to it, will produce 15.

Yes.
In practice you can reuse impure return values as many times as you like without the impure function reevaluating
If you reuse a pure return value it gets evaluated once per impure function call.

So place your heavy calculations in impure functions and make several pure nodes if you want the pure node to be evaluated more than once per impure call.

Thank you for the confirmation @GarnerP57, that should resolve this question.

Yes, in other words, the node produced two number. Once for each line.