Blueprint recursive call causes wrong parameter

When calling Events in Blueprints recursive, the parameter of the Event is wrong after returning the recursion. This causes very strange behaviour in my project where the recursion is called indirectly through other blueprints.

I could reproduce the behaviour with the following Blueprint.

Used UE 4.10.2 Launcher Version.

Hello user37337,

After looking over your post it appears that you are reporting the print string being called more than once. If this is not the case, could you explain your issue further with a more concise description of how the actual result is at an inverse to the expected result?

This appears to be working as intended. The print string in this case will be called more than once. This is because “Name” is set to “Test2” on Then 0, this means that by the time Then 1 is called it has already been changed to “Test2”. That is call number one. After this the second call of the custom event “Test Recursive” needs to be resolved. This is when the print string is called a second time.

Flow:

Begin play > Call Test Recursive (sets Name to “Test1”) >

Firing Test Recursive > Sequence > Then 0 > Branch (True) > Call Test Recursive (sets Name to “Test2”) > Then 1 > Branch (True) > Print String >

Firing Test Recursive > Sequence > Then 0 > Branch (False) > Then 1 > Branch (True) > Print String

Make it a great day

This is exactly what I mean. Maybe this works as intended but not as expected.

The Name type is a Value Type that is passed as Function Parameter to the Event. So the second recursive call shouldn’t change the Parameter of the first recursive call because this value is a level below in the Stack.
Even if the Parameter is passed by reference the referenced value of the first recursive call is never changed so the parameter of the second recursive call is a new reference.

In any other programming language this example will call “Print String” only once.

Same bug was reported here 6 months ago: [Bug] Blueprint Event Arguments Fail Recursion - Blueprint - Unreal Engine Forums
Hasn’t received any attention.

It seems this is an issue only with BP events, not BP functions. Evidently their parameters are being allocated globally rather than stacked.

@Rudy: Your execution flow is wrong - the second recursive call is fully executed before the first call reaches ‘Then 1’.

Is there any chance that this behaviour will be fixed in the future?

After going back through and speaking with some developers I was able to find that this appears to in fact be an issue. I have written up a report ( UE-25551) and I have submitted it to the developers for further consideration. I will provide updates with any pertinent information as it becomes available.

Make it a great day