Add C++ code to Blueprint project

I have a general question on mixing C++ and Blueprints. When creating a new project in UE4 I can select either BP or C++. I know that I can add Blueprints to a C++ project easily. Also I have seen in the documentation that I can add C++ code to a Blueprint project.

However when I do the latter, is there any drawback in comparison to “real” C++ projects?
Or in other words: Do I have all the same options when I add C++ code to a BP project that I would have with a “real” C++ project?

1 Like

Personally, I usually start with an empty blueprint project so that I can set up some variables first in the editor (copyright, project name etc) and then when I add code to the project, which creates the visual studio solution and project files, it gives me a rather clean slate with minimal default classes added for me (i.e. no custom gamemode class, etc added by default). If you create a code project right from the start, it generates more classes by default. I’m just a control freak and prefer to add exactly what I need myself lol :stuck_out_tongue:

Also, if starting from a blueprint project, before adding any code to your project you can go to the directory where your project is stored and manually add the Source directory and create the Public/Private folder structure if you prefer that structure (i.e. MyProject/Source/MyProject/Public and MyProject/Source/MyProject/Private). Then when you add code, the editor will acknowledge the public/private folder hierarchy when you add code from the editor. I do this personally but I suppose it’s just a design choice. Just a side-note, the editor also now respects module folder structures when adding code as well. Only problem I’ve found so far is that using a nested subfolder structure within the Public/Private folder structuring will only automatically read 1 subdirectory deep when compiling in editor after adding fresh code to the project (i.e. MyProject/Source/MyProject/Public/SomeSubdirectory/). It still adds the code just fine to the solution in visual studio, it just mean you’ll have to compile the editor again from visual studio for it to display the newly added code assets in the editor if your subdirectories go deeper than 1 subfolder beneath Public/Private.

1 Like

Thanks for your quick feedback. So does this mean that I will get all the same features from adding C++ code to a BP project as I would have from a C++ project in the first place? Or is there anything I could not do with adding C++ code to a BP project later?

Yeah you won’t missing out on anything except a few classes that the c++ project would have auto-generated on creation (custom gamemode and 1 or 2 others).

1 Like

Good to know, thank you very much!