Manual Return node

Hey guys
There is no way to set an empty return node for the exc feed, i am manual writing a function and i am trying to add a return node to this function and there is nothing in the blueprint classes.

I can return a value that will create the return node, but say i don’t want to return anything just return, i can not currently do this manually.

It’s probably because an explicit exec out pin simply isn’t needed when nothing is to be returned.

When you call your function later on, the caller node has its own exec out pin, so the execution flow will pass through as expected anyway. Therefore, adding an otherwise empty return node at the end of a function would just be a superfluous decoration.

This actually mirrors standard C/C++ coding practices. A proper function would always return a value, and you would explicitly use the return keyword along with the value to send back to the caller at the end of it. On the other hand, if it doesn’t return a value, then it’s not technically a function but a procedure, and as such it just ends when the code block ends, without an explicit return statement (unless you have some optional early bail-out based on a switch or similar).

In short, when you’re building a BP function that does not return anything, you are in fact building a procedure, and procedures do not need a return statement.

Ahhh i thought it was necessary to the way it works, if not then that’s all good :slight_smile:

And what should I do if I need to interrupt current function? For example: I have three arrays and I’m searching through them some value. If I found my value in first array I won’t search it in another two. How I should inteerupt such behaviour? The only way is to create a boolean variable and check it if I found my value. After first loop I got to check state of that variable and decide to search in next array or not. And I must do it because there is no just empty return node which I want to call right after founding my value in some array.

This is not a standart C/C++ practice.

Hey Alanir-

You could use a ForEachLoopWithBreak node to cycle through each element of an array. As part of the Loop body you can use a branch node to check the current array element for the value you’re looking for. If the branch is false (did not find the value) then continue with the loop body and if the branch is true (the value was found) then you can immediately break from the loop.

Hello ,

Yes, but I have THREE foreachbreak loops. I’m interrupting one and by “Complete” exec node calling next loop for next array. There is no output flag from loop which mentions that loop was breaked or not.

Just to clarify, you are wanting to be able to return from a loop immediately without having to run through everything connected to the “Completed” pin, correct? If this is the case, one option would be to edit the ForEachLoopWithBreak node (by double clicking on it) and adding an additional execution pin to the output node. Then from the branch node inside the For Each Loop create an additional branch that checks the local boolean (break condition). If this second branch is true (the break was triggered) then you would execute the new “break out” execution pin. If the branch is false (the break was not triggered) then you would execute the Completed pin

Yes, I’m talking about such situation. I can rebuild engine for my needs and fix all blueprints which I need. But tomorrow another developer will ask you that question again as I did. Tha example is just one situation where people need return node.