Mix BP and C++: How to tackle Blueprint Recurse Limit Exception


I’m making a circuit simulator game, which consists of nodes and wires that are currently implemented as custom BP Actors (with mesh components, box colliders etc). However, I’m hitting the blueprint recurse limit (detailed in this answer) when executing a long circuit.

As I understand, this a purely BP VM issue, so I’m trying to avoid this problem by moving the recursive execution logic to C++. But I don’t want to move the entire BP Actors to C++ classes since I would like to retain the ability to manually arrange components in the BP viewport. (I know we can compile the engine from source to increase this limit but I don’t wanna do that. And no, the execution logic can’t be converted to loops.)


Can C++ functions be sprinkled in existing actor BPs’ execution logic, without it adding to the BP recursion limit? Or does it make more sense to entirely convert the BPs to C++ classes to avoid the limit entirely?

Update: I tried making a test BP actor and a test C++ actor, with a simple recursive function that halts on a global maxCount reached. BP actor fails at 80th recursion, whereas C++ actor seems to work fine no issues (tried up to 5000 recursions).

So there’s hope. Will update.

For anyone who stumbles across this, here’s how I solved it:
I ditched the recursion approach, and created a global queue. Potential invocations get added to this queue, and looped over, firing each.