C++/Blueprint Class Hierarchy and Coding Pattern

So I’m transitioning from a Unity mindset to an Unreal mindset with development and would like to know if I’m on the right path.

After fumbling around with blueprints, I’ve found them to be pretty fun to use, but I keep hitting roadblocks and needing to superclass them in C++. This led me to think maybe I should always use C++ superclasses and only reference them instead of the overridden blueprint classes, which basically leaves blueprints for overriding default values, adding components, and implementing specialized behaviors.

I haven’t tested this very thoroughly, though, so I’m not even sure how robust it will be, or if it even works as I expect. Before I get too deep and make this my standard, I’m wondering if anyone has different ideas/practices that might work better.

The example I’m working with is an RTS. It would probably be easiest to visualize with the pseudocode:

	class Faction {
		// These are all initialized in the constructor using iterators for their c++ class
		TArray<VesselUnit *> Vessels;
		TArray<StructureUnit *> Structures;
		TArray<AddonUnit *> Addons;

	class Hubert_Faction : Faction {


	class UnitBaseClass {
		UStaticMesh *mesh

	class VesselUnit : UnitBaseClass {

	class Fighter : VesselUnit {

	class Tank : VesselUnit {

Then I can create a Hubert_Faction_BP blueprint, add some Hubert_Fighter_BP and Hubert_Tank_BP child actor components with their static meshes set, and I can easily use class iterators within C++ or within Blueprints.

So far, this seems to have several benefits.

  • IMO, It presents a cleaner class/blueprint hierarchy than just a bunch of base classes.
  • If I need a virtual method that can be overridden by blueprints, I use UFUNCTION(BlueprintNativeEvent), and it’s easily callable in C++.
  • If I need to implement a simple algorithm, I jump back to the code and quickly implement one instead of having to mess with the spaghetti of blueprints.
  • I can easily iterate all actors using the C++ class iterators.

I’m interested to know if anyone sees any critical caveats with this that will present a brick wall down the road.

I’m also coming from Unity to Unreal and I’ve come to similar conclusions. I don’t see any reason not to start any new class as a C++ class. If you start with C++ you can always extend to Blueprints, but you can’t really go the other way around.

The way I’ve come to think of Blueprints – which might be wrong, as I’m only a couple weeks into this – is that they’re basically Unity prefabs except that they can also contain code. So in Unity, a prefab is a bucket of components with prefab-specific configuration values, and if you want to add some more functionality to a prefab, you add another component which implements it. In Unreal, a “prefab” (Blueprint) is still a bucket of components with prefab-specific configuration values, but if you want to add some more functionality, you do it directly on the prefab/Blueprint rather than by adding another component. (Although you can add another component if you want.)