C++ actor in blueprint project

On the content browser (on the source section, C++ Classes or wherever you want really) press right click and create a new C++ Class.
image

Select Actor

Then select where you want to create it, and its name (it can be changed later)

Then it should open your text editor (visual studio, rider, or whatever you have) on the just created class. Code it as you want.

image

In the header file you can add specifiers to the UCLASS(), for this example you will probably need BlueprintType and Blueprintable.

image

Compile it and now you can create new blueprint classes that inherit from AMyActor (or the actor you created on c++), you can also assign variables in BP as that class, for instance another class that has a variable of type AMyActor can now be used.

This doesn’t convert your project from Blueprint to c++, it just creates a class created on c++ that can be used alongside blueprint classes. Notice that blueprints are assets while cpp files are source, this means that blueprints can use c++ classes without any problems, but the same CAN NOT be said otherwise, using/referencing a bp from a cpp file is something I’m not sure is possible, and if it is, it will be a source of many headaches.

Hope this helps!

1 Like