Multiple event inputs vs single event/function?

Now this is just a simple example. Let’s say it has 100 nodes.

Does this actually create 2 events with the same code?

In which case, it would be better to have only the custom event run the chain, and have button click call that event?

I’ve often done the former because blueprint-wise it’s the simplest action. But thinking about it now it probably creates duplicate code?

not sure.the two examples are totally different to me.the above is two separate events.below is basically only one event.

For several reasons, blueprint nodes are unique and the compiler cannot just duplicate them for the heck of it. Each output pin behaves pretty much like a global variable. It’s possible to connect the output pin of a node from one exec branch, to the input of a node in a different exec branch.
For example :

if the compiler would generate duplicate code for events A and B, then it becomes ambiguous which input the PrintString is connected to.

Latent nodes also have their own reason for being unique. There’s an expected behavior when code re-enters a latent node which is already executing. See how “Delay” and “Retriggerable Delay” behave when called repeatedly.

The compiler/machine code relies a lot on jumps, and that’s what will happen there. For example the entry point for OpenOptions will go straight to the execution of the node, while the entry point for ButtonClick will jump to the OpenOptions execution path. Or the other way around. No duplication. Maybe the two events will even share the same entry point.

Compiler will do essentially the same as what you did in second image, but with better performance. Function calls are quite expensive in comparison to a single bytecode jump instruction.

1 Like

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