How to make a C++ class inherit from a blueprint?

Hello,

First of all, I would like to clarify that I am a beginner and I have been using Unreal Engine for 2 weeks.

I have a problem trying to integrate blueprints with C++ code.

Regarding the architecture of my project, I started from the principle that I should create a C++ class for each blueprint (where the blueprint will inherit from this class).

However, the issue is that if I create a blueprint that needs to inherit from another blueprint, then my workflow won’t be possible.

Here’s an example where I have 2 classes, Gun and Rifle, which inherit from Weapon. I do have a blueprint that inherits from each corresponding class in C++.

What I’d like is for AGun and ARifle to inherit from BP_Weapon so that when I create, for example, a BP_Gun, the code from BP_Weapon is executed. In terms of architecture, it would look like this.

I understood that it was not possible for a C++ class to inherit from a blueprint. As a result, I find myself stuck and I’m not sure how to architect my project to make blueprints and C++ coexist. Do you have any advice or ideas?

Thank you

Once you are in the blueprint world you are pretty much stuck in it. In general I tend to do as much as I can in C++ and only do the last step in blueprints. So all the base classes, everything that could be abstract, are a good candidate for C++. Then I create BP classes out of that which defines data like the actual used meshes, tags and so on. I add class specific components like audio components or additional meshes that are not being used in the base classes. Also I often bind to dispatchers of my used components here. I rarely have any abstract BP classes or a more than 2 levels deep blueprint inheritance. In my opinion there’s no real need for a “every BP class should have a C++ parent” rule.