Unreal Engine 5

How to Convert a Blueprint Only Project to a C++ Project

While writing the article on C++ Modules in Unreal Engine and the article on the Event Manager in C++, I realized that the reader might have created a Blueprint project and thus may not be able to integrate the Event Manager into their project. In this article, I will briefly show how to turn a Blueprint-only project into a C++ project.

Why would one want to convert a Blueprint into a C++ project? I came up with the following reasons:

  1. Performance: C++ is notorious for its speed and efficiency. In large, complex games, where every millisecond counts, switching to C++ can make a noticeable difference. It's like the difference between a sports car and a family van - both get you to your destination, but one does it much faster.

  2. Control and Flexibility: C++ gives you the freedom to do really anything. You can delve deep into the engine and adjust things that Blueprint developers can only dream of. It's a bit like having a Swiss Army Knife in the wilderness - you're prepared for everything.

  3. Scalability: For larger projects, C++ can help keep the code cleaner and more organized. It supports complex, tailor-made systems that can quickly become confusing in Blueprints. Imagine trying to assemble a giant puzzle with oversized pieces - in C++, the pieces are finer and fit better.

  4. Long-Term Maintenance: In large projects, where you might spend years maintaining and extending, C++ can be easier to maintain than Blueprints. With good code design and comments, you can find your way around even after a long time, and new developers can more easily understand the logic.

  5. Community and Resources: C++ is one of the most widely used programming languages in the world. You're no longer just limited to looking for solutions specifically tailored for Unreal Engine, as C++ is used universally, unlike Blueprints. Therefore, there is a huge community and a wealth of resources to learn from, including the articles I publish.

Of course, Blueprints have their place and I don't want to deny their validity, and it's not suitable for every project or developer. Blueprints are great for quickly creating prototypes and for smaller projects or teams that don't have the resources to delve deeply into C++. Personally, I try to prototype gameplay functionalities in Blueprints first and then, when the graph becomes too large and confusing, either translate parts of the functionality into C++ or pour the entire logic into C++. Blueprints have the advantage that you can make quick changes and test them, which is really handy in the concept phase. But when you reach a point where performance, control, scalability, and long-term maintainability are priorities, C++ might be just right.

However, I tend to translate 100% of my code into C++, if possible, as I prefer my implementation not to be distributed between Unreal Editor Blueprints and Visual Studio Code, but to live centrally and completely in the C++ code. This is just a personal preference.

Requirements

Install Visual Studio

Assuming you've never programmed in C++ before, you'll need to download and install Visual Studio Community Edition. Visual Studio Community is free and can also be used for commercial projects, so you can install and use it without hesitation. I usually just install the latest version and make sure I have Game Development selected in the additional features menu, as there is Unreal Engine integration that can be installed along with Visual Studio.

Convert Process

So, you've created a Blueprint project, stumbled upon my tutorials/articles and might be thinking: "Darn, when I created the project I wasn't interested in C++, but now I want to use the cool advantages, but now I have a Blueprint project and can't use C++ code and don't want to rebuild all my Blueprints in a new project and export all assets." Don't worry. You can also convert a Blueprint project into a C++ project and keep your current progress on the project without having to do everything anew.

Creation of new Unreal Engine Blueprint Project

For this, I've done it myself and documented the steps that were necessary.

Step 1: Open your Blueprint Project

Unreal Engine Content Browser is Missing C++ Classes Folder and there is no Button to Create a new C++ Class

When you open your Unreal Engine project, you will have noticed that you don't have a C++ Classes folder in the Content Browser where you can create C++ files, and you also lack the button to compile the C++ code of the project. To get both the folder and the button, you actually just need to create a C++ class.

Step 2: Create Your First C++ Class

Create a new C++ Class using the Tools Menu

Since you can't create a C++ class in the Content Browser without a C++ Classes folder, you can go through Tools -> Programming -> New C++ Class instead. I usually start by creating a Game Instance class, as it provides an important foundation for every Unreal Engine C++ project in my opinion.

Step 3: Create a C++ Game Instance

Create a C++ Game Instance for your Project

You could scroll through the Common Classes until you find the Game Instance, but I usually just go through the All Classes tab and search for GameInstance, where I find several options for derivation. Simply select GameInstance and click on Next>.

Chose a name for your new Game Instance Class

Here, you can name the Game Instance. I usually follow the pattern of replacing the My in the name with the project title, so I name my GameInstance class [ProjectTitle]GameInstance and create it with a click on Create Class. You can also decide whether to create the class in the Public or Private folder. Public allows us to access the class from all other modules, while Private ensures that it can only be accessed within the module. This is something you should definitely keep in mind.

As I don't want other modules to have access to my Primary Module, I always create all classes as Private C++ Class. I would recommend that to you as well. If you encounter limits and you absolutely must call classes from the Primary Module from outside, you should perhaps rethink your architecture at that point.

Step 4: Convert Project (Close Project)

Wait for Unreal Editor to add code into project

This step consists mainly of waiting, as your project needs to be converted.

Warning Message you will see if you create your first C++ Class

The first time you create a C++ Class, you will be warned that your project now contains Sources and you must close the Editor. After the new GameInstance C++ class is created, you will be informed that you need to recompile the code.

Message after C++ Class was created successfully

When asked if you want to edit the code now, click Yes and wait for Visual Studio to open with the source code of the project.

Visual Studio Project that opened after clicking Yes

After the Visual Studio project has opened, you will find the code there and also the newly created GameInstance C++ class. Then close the Unreal Editor.

Step 5: Build Your Project

Bild your Project by clicking on Build

Next, build your project in Visual Studio. You do this by right-clicking on the project and then clicking Build in the context menu. This may take a while. If the build fails the first time, just try again. I had to build my project twice for it to be successfully compiled.

Step 6: Start the Unreal Engine Editor

New C++ Classes Folder and Build Button appeared

Now you can open the Unreal project and two things should have changed:

  1. You should now find a new folder in the Content Browser called C++ Classes.
  2. You should have received a new icon in the bottom right corner, with which you can start your build of the C++ code.

Click on Build Button to compile C++ Code of your Unreal Engine Project

Now you can simply click on the build button and the editor should compile your C++ code for you. If you want to edit a C++ file, you can just search for it in the Content Editor, and open it with a double click. This should open Visual Studio with the file open in the text editor.

Disable Live Coding Feature because it causes errors

The first thing I do in a C++ Unreal Engine project is to disable the Live Coding feature because I first make Blueprints out of the Widget C++ classes before I integrate them into the project, so I can do the positioning of the images and texts in the Unreal Editor, and the Live Coding feature has caused the Blueprints to lose their assignment to their C++ Parent Class several times, and I had to redo all the work I put into setting them up. After several crashes and having to redo it several times, I permanently disabled the Live Coding feature and will not turn it back on.

Compil Complete! After second try

As you can see in the screenshot, I also needed several attempts to build the code. Allegedly the build tool was already busy, but after a second click on the build button, it then worked.

Conclusion

Switching from Blueprints to C++ in Unreal Engine 5 can be intimidating, but it's a journey worth taking. You not only get better performance and more control but also learn a skill that will take you far in your developer career!

If you have never worked with C++ before, expect a steep and challenging road ahead, but I'm sure it will be worth it. I wish you much success!

Profile picture

Artur Schütz

Senior Software Developer specializing in C++ graphics and game programming. With a background as a Full Stack Developer, Artur has now shifted his focus entirely to game development. In addition to his primary work, Artur explores the field of Machine Learning, experimenting with ways to enrich gameplay through its integration.