Interaction between C++ and Blueprints

Hi All,

I am trying to do heavy math in BP and get the “infinite loop detected” error. Other threads recommend moving the math to C++ Code to make it possible and enhance performance.
My question: How would I do that?

Can I create a Function in C++, pass the value that I need into it and let it output the corresponding value to my BP so that I can use it further on?
Will this setup really boost performance and allow for heavy math? Sounds too good to be ture for me, haha

Thx in advance

Yes absolutely. You can create classes in c++ that can be called from BP, returning results. Check out:

Thanks very much!
But what is the rationale behind it being able to handle complex calculations that BP can’t? I mean it is just math… xD

c++ is always going to faster for math and tight loops by quite a bit - when you get to the point of triggering BP infinite loop timeouts, it’s time to either change the algorithm or dive into c++…

BP is a limited layer built on top of c++ which in the end has to translate back into c++ and generates a ton of extra data as well. But your infinite loop problem points at a problem with the code, no matter if it is BP or c++. It is highly unlikely any blueprint would hit the calculation limit triggering a infinite loop warning (limit set in project settings), so you should triple check the bp code first.

“To change the algorithm”
Yeah, but I am really not smart enough to figure out a mathematical relation for this optimization problem

@Roy_Wierer.Seda145 “Tripe check your code first”
I did that many times. All I am doing is trying to create the cartesian product of three arrays with 22 elements each (22^3 = 10,648 iterations) and I am sure that my setup is correct. Still I get the timeout issue.
Buddy here had the same issue (https://www.reddit.com/r/unrealengine/comments/6z1pi2/infinite_loop_detected/) and they said it is due to the nested “for each loops” which I also have.

Let’s see if I can get it to work in C++ instead

Thanks for all the replies!

1 Like