I have a pure blueprint function that returns a value based on a simple condition.
Now when the condition is not met anymore and the function has no return node, the last valid path is returned.
In the case of this example, when the condition is false, the node still returns a value of 150.
I wonder if this is expected behavior or a bug ?
Either returning zeroes or a log warning would make more sense and be less prone to errors.
This can easily be reproduced and i have included a test project in the post that shows the issue.
Adding another return node will instantly solve the problem.
The blueprint should exactly work as the code you posted there.
If the condition is not met, it would basically return the float as 0 without the need to define a extra local variable . Like having a virtual return node.
Thanks. Just thinking for Blueprints it would be more convenient to be able to just skip the return path and have some sort of virtual return node.
In C++ making such a mistake, like forgetting a return path is pretty much impossible.
from a non programming perspective i would say that the value is statically set. i realize that the value shouldnt be set from a code perspective until the node is called but its probably one of those quirks of blueprint.
I think this is very prone to errors in Blueprint. Now after looking at the nativized code, i realized it uses a void function with a pass-by-ref parameter and not a float function(Which does make sense). In C++ the code below does the same as Blueprints, but there you would be alot more careful. It’s not that big of an issue, just alot more convenient and easier to debug if you forget a return node in a complex blueprint function.