Node to Code from Blueprint Editor

Hi all. I’ve been tossing around ideas about automating the conversion of BP into C++. While others seem to be taking the approach of converting an entire blueprint, perhaps all we really need is a way to convert a series of nodes into a single line or chunk of C++ code. What I propose is a feature that allows you to select a node or series of nodes, right click, and click on a new menu item called Node(s) to Code. The nodes and connections between them are then analyzed and converted into a line or lines of formatted C++ code on the clipboard, where it can be pasted in to visual studio and adjusted. This would save lots of time typing out these lines by hand.

But you would need to pick nodes that have single common orgin in order for them to create code sequence

Unless I got the concept wrong, but isnt that whats happening when you “compile” a BP ?

As far as I know: no

compiling a blueprint results in bytecode. This bytecode is executed. You can read more about bytecode here:

There are all kinds of optimization techniques one can implement to make the execution very fast. Java and .Net are quite good at this. I dont know what optimizations Epic has implemented. I dont know how it was measured, but a while a go I read somewhere that a blueprint is around 10-20 percent slower. But I guess it also depends on what you are doing in the blueprint.

Blueprint is slower than that. C++ is up to 1000% faster than Blueprint. The biggest slowdown though, is the transition between the VM layer (bytecode) and the native (C++) calls. So the fewer nodes you have, the faster your code. Collapsing nodes to functions of course just moves those nodes to a new graph - to see gains you’d have to rewrite those nodes into a single C++ function. For the most part though, speed differences are imperceptible. Only when you’re stringing together many complex nodes will you see marked slowdown, at least in my experience.

You are correct, I looked it up… it wasnt 10 percent slower but 10 times slower. Bit of a difference :stuck_out_tongue:


I want to apologize for this Necro however I believe this would be an amazing feature. I have the impossible in mind like you right click a BP file and hit ‘Generate C++ Script’ takes some time to convert it. Open it in VS and learn what you just did in Blueprints.

This would be an amazing feature for the visual scriptwriters to have that same power and optimization but also, the best learning tool out there for C++ people would go absolute nuts for this. Hell I would pay a fair chunk of change for a plugin that had this functionality.

I understand that somethings aren’t possible tho however this shouldn’t be buried would be nice to get an Official Yes this is possible and we will aim to achieve it or simply sorry this is not possible.

Apologies for necro.

I would love to do it, but Im still in the lower regions of the C++ learning curve…
If someone is willing to help me with some C++ related “issues” (mostly syntax and UE4-api related), Ill give it a shot :slight_smile:
Writing parsers is my hobby :smiley:

There is code in the 4.8 and 4.9 about new system for Blueprint and probably for the 4.10 there should be the new compiler the Blueprint will be converted and compiled in C++ for the release versions of the projects and that boost the performance and speed of the Blueprints to the same or more or less the same of your C++ code.

That would be amazing…

I would literally be so happy with this, it means there is even less bad implications from writing all code in Blueprint. I don’t write in BP because i’m to lazy to learn C++ or it’s to hard. Its just very fun and I am a visual learner. But I would also like the feature to scan through the created C++ files so if you wanted to learn C++ from this you could say “Ohh that’s how to write a function in C++” etc… However I would be happy with just compiling to C++ for that performance boost.

Its a shame there is no mention of this yet… Would be something to get quite excited about.

I did a simple map spawning 800 flying missiles using AlFlakky’s Homing missile blueprint and converted C++ version to find out how much speed difference between Blueprint vs C++, here’s my finding:

In 4.8.3

Blueprint: 36 fps
C++: 42fps

In 4.9.x (latest github 4.9 branch)

Blueprint: 38 fps
C++: 41fps

In 4.10.x (latest github master branch)

Blueprint: 42 fps
C++: 42fps

Well, I always assume the “10x slower than C++” blueprint performance too until I did the test. It’s a simple level with only 1 blueprint so don’t take the speed comparison too seriously, but it proves that “10x slower” is indeed **rough **rule-of-thumb depending on lots of factors.

They say its 10x slower but it shouldn’t be as i’d assume that it is writing the script and placing each piece of code as your placing your nodes in real-time. E.g Bool.

I think if its working like that if then the only thing that would be slow would in fact be how fast your placing each node.

Thanks for the numbers there Nate.

Would be nice to get a real stress test doing the same exercise you did.

Something really quite challenging like worst case scenario.

Still looks to be pretty awesome.