Execution pins inside functions

Hello, I’m testing a very basic code to count ammunition.



The Ammo Fire Check function’s return node is not called when the ammo count is zero. However, as you can see above, the output execution pin is activated.

So, why is that happening?

A macro behaves like that, functions do not.
Functions return regardless of what occurs inside them.

If you want to change logic based on what the function does, you need it to return something, such as a bool, which you can then check and decide how to proceed.

You’ve got a few things jumbled up here.

Functions are for ‘getting something’, like getting ammo amount after reload etc.

Custom events are for ‘doing something’, what you have there is best done by a custom event.

But… if you want the effect you’re describing ( where the output pin doesn’t fire ), then you need a macro ( also for doing things ).

The function is designed to pass execution on, even when it doesn’t return a value.

As I understand, a function’s output pin will always get activated when the code inside the function has finished executing. In your case, it looks like execution reaches the branch node and tries to follow the “false” path, which is a dead end. So execution for this fuction finishes and the output pin is fired, otherwise your program would just stop.

Just like in C++ you don’t need to type return to finish your function, but you can type it to interrupt it.

Ok. I hadn’t heard about macros in Blueprints. Thank you!