Hi.
My project is a C++ First person shooter template. What im trying to do is take the character class that you get as a default and build functinality on to and around that character.
It all compiles and works fine untill i add an inheritence to this class. The child of the character has to have a reference as an inparameter in the constructor like this:
char.h
ATE_D_Character(const FObjectInitializer& ObjectInitializer, ATE_A_Character& inCharacter);
char.cpp
ATE_D_Character::ATE_D_Character(const FObjectInitializer& ObjectInitializer, ATE_A_Character& inCharacter) : Super(ObjectInitializer), mCharacter(inCharacter)
{
}
When you try to compile this it gives you an error saying: “You have to define ATE_D_Character::ATE_D_Character() or ATE_D_Character::ATE_D_Character(const FObjectInitializer&). This is required by UObject system to work correctly.”
So to fix this I define one of these two functions and this error is now gone. This kind of breaks the logic to the class but its not a very big deal.
However, I now have a constructor that does not take an ATE_A_Character Reference and that means that the reference I have as a member in the .h-file goes uninitilazied and the compiler throws an error at me saying it is uninitilazied. Is there anything I can do to be able to skip that constructor that does not have my reference in it? Why does UE4 need that specific constructor when the constructor I want to keep turns into this constructor down the line as the parent only has the constructor that UE4 wants?
I cant really use anything else than a reference there either, I’ts pretty crucial to the functionality i want.