I have a recursive function that sorts every player and enemy by speed (from lowest to highest) and returns the result in an actor array.
Inside the function, when it is about to return, the array is correctly populated, but when I check the resulting array that is set after executing the function, it is always empty. It seems as if the return array isn’t passed to the function.
im surprised you dont have any looping errors. it looks like your trying to call a function from inside itself, ive never tried that but it seems wrong.
It works fine, up until the point I actually return the array, where it is always empty. But if I print the contents of the array just before returning it, the function has done its job correctly.
Are recursive functions that uncommon in Blueprints ? They’re very common in traditionnal programming languages.
I set the result of the previous function in a local variable directly when starting the new one, so it should be working when I return that value to the main blueprint.
I finally solved my problem by making a non-recursive version of my function, and it’s better in every aspect : size, readability, speed, and memory usage (not that memory is an issue, but still).
What do you do “outside” of this function? How are you using the output array?
If “list buffer” is a local variable are you using it as the output to set a “class variable” somewhere outside of the function? (as I mention in point #1)
Also your “test” with the “make array” thing would be empty…you haven’t hooked anything into the array pins