Blueprints - Not connected execution paths return unexpected value

Hello there, I have just recently started using blueprints and come from a programmer background. I am currently developing a game and love the editor and the concepts of blueprint programing. I have now spent around 100 hourson a project and have created some complicated logic that utilizes many different blueprint classes, interfaces and enums.

To the problem:
So originally I assumed that if an execution path is not connected to a return node within a function, a default value would be returned or at least an error would occur. But recently during some debugging sessions I have noticed that almost all the bugs that I have encountered so far are because some execution pins where not connected to a return node leading to an invalid return value.

What actually happens seem to be that the return value is based on an already existing return node within the same function. I have found the following Question and I understand why this is happening. But my question is, is it possible to have some sort of validation for this in the editor? Either total error and not allowing to compile in the editor, or at least having some sort of possibility to find all “problematic” blueprints?

For now, I can just go and fix the existing problems when I encounter them, but I can imagine I could introduce some bugs due to human error when creating future blueprints. Any help is appreciated, Thank you in advance!

blueprint functios without any input are totally valid and dont throw errors.
Are void functions. (a function without a return value)

if the function has a return type/variable then all execution paths should lead to a return node that returns that value

theoretically you should also have functions without a return type/variable also go into a return node.

the reason why it is “technically” OK that not all execution paths of a function go to a return node

  • Blueprint Functions are derived from Blueprint Events, and Events don’t actually return they just stop.
  • the Sequence node exists which means that the blueprint compiler would need to take potentially longer passes (in my mind the blueprint compiler is only really compiling one thing at a time, and I would rather have it take a little longer and not produce nothing/garbage/crashes)

for analyzing blueprints to find if the final node in the execution path of a blueprint function is a return node would probably be done using a Python plugin, or modifying the Engines source, (so for most projects a Python plugin)

Alright, I was hoping there was a simple way to have a warning about this in the editor but I will take a look. Thanks for the help!

if it hits a code path that does not return, then the function returns None and you should get some pretty annoying log warnings when you try to access the return value.

BP functions are not based on BP events, blueprint as a whole is a cover of paint put over the old UnrealScript, and events and functions basically are interchangeable except for a few bits here and there.

None would have been good, to be honest… The problem is it can even return true for boolean outputs which was quite unexpected.

yeah, None basically blows up the comparison operators. And that’s why you get a Blueprint compile warning, and you get a runtime warning in the log when you try to do these things :slight_smile: If you’re returning a Name or an Object or a Class, then you’ll get a proper ‘None’ result, but otherwise you get … junk.

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