C++ output params setup for a forloop node

No, you can’t replicate a ForLoop node using the ExpandEnumAsExec meta markup. It’s not possible for a plain UFUNCTION to trigger multiple outputs in a way that looks like the ForLoop/ForEach node.

You’d have to resort to an entirely custom blueprint node. I wrote a tutorial on that a few years back and nothing’s really changed from UE4 to UE5.

Improving UE4 Blueprint Usability with Custom Nodes - Engines and Middleware - Tutorials - GameDev.net

It also links to a github repo I setup (GitHub - MagForceSeven/UE-K2-Nodes: Examples of custom K2 Nodes for use in Unreal Engine 4/5) to show an example implementation of a ForEach node that allows iterating TMaps (something the engine surprisingly lacks). It also includes a reimplementation of the ForEach macro in native, but only because the macro is inaccessible to the ForEach node I was trying to make.

However, there’s really no good reason to re-implement it just for it to have a native implementation. If perf really comes down to a for loop, you should probably just reimplement the whole loop in native instead of going back and forth between native (for the loop control) and blueprint (for the body).

1 Like