Ability to subclass Blueprint from both, C++ and Blueprint class, simultanously.

Currently we can create Blueprints using subclass of C++ class, but what if,
we have C++ class hierarchy: ANpc : AActor, ASuperNpc : ANpc.

Then we would like to create NpcBP : subclass ANpc, in which we will create and arrange Components for Npc,
then we need to create SuperNpcBP : subclass ASuperNpc, in which we want already to have NpcBP components/variables, and we want just replace Small Head Component with Big Head Component. But currently SuperNpcBP has only ASuperNpc subclass without NpcBP subclass.

So, what i suggest:

When you create Blueprint, you could inherit it by 3 methods:

  1. Blueprint : only base C++ class. (when you create SuperNpcBP in editor, you specify only ASuperNpc C++ class)
  2. Blueprint : base C++ class and base BP class. (when you create SuperNpcBP in editor, you specify ASuperNpc C++ class, then ue4 detects base class of ASuperNpc (it is ANpc : AActor) and if it is not directly AActor/UObject and also Blueprintable, then editor suggests you to specify also NpcBP blueprint class, which has to be inherited from ANpc C++ class).
  3. Blueprint : only base BP class. (when you create SuperNpcBP in editor, you specify only NpcBP blueprint class)

Currently, you can do only (1) and (3), but not (2).

PS: i know, thats crazy idea, but anyway. I am also not sure is it good idea or bad.

Currently i could create ANpc C++ class, and then create NpcBP : ANpc, and then create SuperNpcBP : NpcBP, but in such case i am not able to add SuperNpc specific C++ code.

Currently i could create ANpc C++ class, and then ASuperNpc : ANpc, and then create SuperNpcBP : ASuperNpc, but in such case i am not able to have base blueprint NpcBP, which could contain reusable component structure and variables for derived blueprints, so i have to implement base NpcBP specific blueprint code from scratch for every new Npc type. Currently i am using this method, but if it would be possible to inherit Bluerpints from both C++ and Blueprint classes, simultanously, then i would have ability to create BaseBlueprintClasses along with BaseCPPClasses, and reuse BaseBlueprints, instead of implementing them from scratch for every new blueprint type.

But Blueprint inherent the same way as C++ class, you can reuse functions, variables and everything it’s inside it down to lowest UObject class. I think you might be confused from fact that by default inherent stuff are hidden, you need to click check box in lower of variable list to show it.

No, im not confused :wink:
Let me explain a little bit more, when you create Blueprint by inheriting C++ class, yes, you have all C++ base classes inherited, but you “can not” create for those base classes “separate reusable blueprint assets”, and then use those assets, when you create Blueprint, along with inherited C++ class.

Currently you can use only following inheritance scheme: DerivedCppBP : DerivedCpp : CppOnly.

I suggest to create ability to use following inheritance scheme: DerivedCpp (may have DerivedCppBP) : Cpp (may have CppBP).

But you can, when you create Object->Actor->ActorBP->NextActorBP->MegaActorBP it will have all code overlap by this chain of classes. I kind of don’t understand what you want to do, from your strange “:” graph do you want to attach blueprint to existing cpp? what “may have” means? mayeb dont use thoise strange “:” and say by full discription

You say use 2 base classes i don’t think its possible, because Blueprint class is same valid as C++ class and it’s bound to same rules as C++ class in class hierarchy. I don’t see how it problem of making BP base class from C++ base class where you reuse in child blueprints, amybe you need to reorganize your code to make it more comfy

“:” means inheritance.
“may have” means may have and may not have (i.e. optional).

You suggest me to use Object->Actor->Npc->SuperNpc->SuperNpcBP->MegaSuperNpcBP,

but i suggest to use: Object->Actor->Npc->SuperNpc->MegaSuperNpc. (C++)
NpcBP(Npc)->SuperNpcBP(SuperNpc)->MegaSuperNpcBP(MegaSuperNpc). (Blueprints)

your version can not have MegaSuperNpc and NpcBP, my version can.

Why do i need this? because i want to have ability to write Base classes not only using C++ code, but also “mixed” using C++ and Blueprint code, so my Blueprints would have the same reusable hierarchy as my C++ classes have. (confused?)

I would call this “parallel inheritance” of C++ and Blueprint code, currently UE supports only “sequential inheritance”.

PS: as i sayed before, this is crazy feature and possibly hard to implement, so its just an idea, i do not insist.

But thats not inherence :stuck_out_tongue: thats more like attach BP code to C++ class

yes, correct

Sounds like what you’re asking for is a combination of mix-ins, and multiple inheritance. Unfortunately, it’s not likely that we’ll be able to implement this kind of inheritance.

There are two major concerns: complexity, and usability.

On the complexity front, we don’t have a way to efficiently go “back across the border” from BP to C++. The reflected information is there at runtime, and serialized in packages, but UHT has no way of getting access to that. You start to run into nasty circular dependencies between script and code, which is something we worked hard to eliminate from UE3 to UE4. As soon as you get conflicting members from C++ and BPs, it becomes a very hard problem to resolve.

On the usability front, I’d worry about exposing the problems with multiple inheritance from C++ to BP users. Once the hierarchies become sufficiently complex, it becomes to get very unwieldy to manage. While your use case is totally legitimate, the complexity quickly grows when you get a diamond pattern inheritance like you’re suggesting.

For the problem you mention above, it’s probably best to add base components at the ANPC level, and then let people modify those as needed in your derived classes.

Thx for such complete answer.