I would like to have full control over when the parent-constructor is called (it seems that UE4 calls it automatically and before the child-constructor). I have a piece of code in BaseEnemy (that inherits from BaseCharacter) that must be performed in the constructor, but before the BaseCharacter-constructor runs.
ABaseEnemy::ABaseEnemy()
{
// <My code that must be performed before the base-constructor here>
// Call super constructor <<<<<<<<< this is not possible?
// The rest of my awesome code.
}
It is impossible to do what you are trying to do. The only way to do it is with multiple bases, but UE4 requires that the UObject base is listed first:
// illegal - UnrealHeaderTool will reject this
UCLASS()
class ABaseEnemy
: public ClassWhoseConstructorMustExecuteBeforeAActorsConstructor
, public AActor
{
};
Then it must have been Javascript or Ruby because I’m sure I used it before in another language not long ago. But indeed both C++ and C# won’t allow it.
C++ allows multiple inheritance, it’s just Unreal that doesn’t. As soon as you put UCLASS() at the top of a class, you’ve got to follow Unreal’s rules.