Download

Migrating BP actor to C++

Aflter 3 months developing only in BP I think it is now time to start migrating some actors to C++.
There’s something that I don’t know exactly how it should be done.
I’ve already created the c++ class with all components inside. I can drag it to the map and it displays just fine.

But…
When I use a BP actor, I can open it in the editor and see how it looks in the viewport and adjust positions, rotations, sizes etc from there.
I cannot do this with a C++ class. This makes it very hard to place the components in their correct places as I have to edit the C++ code, change positions, compile and check the result.

Question 1:
Is is correct if I create a BP and derive it from my C++? I would then be able to visualy see the actor in the editor and maybe adjust positions there. I’m not sure if this is a good practice.

Question 2:
I’m not really sure where whould I set the components positions inside the C++ class. Should I do that in the constructor? Should I do that in OnConstruction override?

Even if you’re doing your primary development in C++, there are still things that make more sense to continue to do in blueprint.

The first is anything visual. Configuring components and their offsets is much easier in the blueprint editor so you might as well do that there. There’s no real downside to having a blueprint, it’s the logic that (sometimes) is an issue. Similarly with UMG (UI), using the Design View to lay out widgets is way faster/easier than trying to do that in native.

The other case is content references. Things will ultimately be better for you if you’re not hard coding references to content and instead you provide places to configure that and assign content in blueprints or other data assets.

This was the path I was taking. Put all the logic in C++ but using a BP derived from the c++ actor so I can edit the components positions and parameters.