Sequences inside Functions

Quick question. If I have a sequence inside a function, will it cause the function to output more than once if there are multiple execution lines leading to the output? I don’t think so, but just want to double check because it would probably add some very hard to track bugs if it does. :slight_smile:

if your function has output there will be execution pin, while i doubt the compiler will detect logical error like early return( say you connect execution line to output before the rest of sequence finished), you can certainly try.

The question is, will a function output more than 1 execution if its internal output execution pin is hit with multiple executions? So inside the function a sequence is hit that splits it into 2 executions and both of those executions lead to the output.

I am pretty sure the function only outputs a single execution, but not 100% sure. I probably would have had countless problems in the past if functions could output more than once.

I am not even sure why the output inside the function takes executions if that is the case. Unless a function has a variable output I generally just delete the function output just to be safe(and tidy).

ahhh…okay…I got what you mean now.
Basically, function will have only one execution pin for its output node.
It can have multiple output “results”(bool, int, float, Actors) pins, but execution pin will only be one.

Only Macro and Collapsed graph can have multiple output execution pins.(sequence is a macro)
It is possible to have two execution path that eventually connect back to output node.
Say, a if/else branch that returns a bool you can connect both True and False output to function output node.
But once you exit a function, with normal programming logic, whatever left in your sequence or loop stopped as well.

I don’t mean pins, I know about that.

The one output execution pin gets hit with multiple executions.

Logically, part of me would think that whatever is outside of the function gets executed multiple times, but that doesn’t happen. Actually, now that I think about it, I have plenty of loops inside functions and they only execute outside the function a single time(when the function is complete).

I guess having an output execution pin at all is kind of confusing because it seems useless. It doesn’t matter what you put on it because it only executes out one time.

I suppose it would matter if the first execution that hits the output cuts the rest of the function off? But I don’t think that happens either.

you can think of blueprint’s function(that has output, if you try define a function without output it become an event.) as inline function that would make more sense to you.
like when you run debug, when ever the orange flow hits one node, it gets run once, loop itself is a macro, even the nodes inside only run once base on conditions and branches.

when ever you hit output node, doesn’t matter if the rest of nodes run or not, the output is fetched.
question being, did you set up the tree properly so there are no race conditions between return one value and setting the value in another execution flow?
While I don’t think Epic would run a function in a new thread(that’s also whey function has to return immediately), keep this part clean is also important.

When you have multiple execution line hit that output, which ever flow hits first should return and the rest stopped.
If it does not behave like this, we’ll see a lot more “weird issues” on this forum.
It should be easy to test with prints and values that gets returned.
Unfortunately I will be out of UE4 for a few days, so you have to test it to clear your doubt.

> When you have multiple execution line hit that output, which ever flow hits first should return and the rest stopped.

I made a function like above. I suppose the function will return when “break” is true.(Sorry about the name) But I found that the GetBlock function will always be called. I haven’t found any explanation about this. Does the sequence node just behaves like that?

From the 4.8 patch notes:

Previous to 4.8, I am pretty sure the return node was basically useless, since everything would execute no matter if something hit it or not.

I haven’t tested it, but it sounds like they “fixed” that since I am sure it confused a lot of people, or maybe it actually wasn’t working as intended.

Thank you, Zeustiak.

I once imported my project into 4.8, but several links were broken so I gave up. But after reading this, I think it’s worth fixing the project in 4.8.

I have tried it in 4.8. It’s OK now.