Hey, I am used to programming in UE3, and just started getting into UE4.
However, while I’m recognizing a lot, I am also confused by some of the new syntaxes for functions (are they called constructors now? Or is that something else?)
I am currently simply trying to call a super in a function so that I can modify it while keeping the parent functionality.
This is what I got so far:
Parent
// Sets default values
ABrawler_Character_Base::ABrawler_Character_Base()
{
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}
You can’t override the constructor like that. Instead, ABrawler_Character_Player will need its own constructor and override any values different from the base/parent class’ settings in that one.
The syntax for a constructor calling the parent class’ constructor looks like this:
ABrawler_Character_Player::ABrawler_Character_Player(string exampleParameter) :
{
// settings for ABrawlerPlayerCharacter_Base and all its children
}
ABrawler_Character_Player::ABrawler_Character_Player(string exampleParameter) :
ABrawlerPlayerCharacter_Base(exampleParameter)
{
// settings for ABrawler_Character_Player
}
For functions, you need to use the virtual and override keywords as described by getnamo and then, yes, call it as Super::Function_Name().
Either way, every function defined in the .cpp file needs to be declared in the corresponding header file (there are exceptions but they’re not important here). I mention this because your class example doesn’t contain a declaration of the constructor. Forgetting this will also result in some syntax errors.
How did you declare the constructor in the header file?
It sounds like you already defined the empty constructor like this:
ABrawler_Character_Player() {};
A lot of the time you don’t need any special code in the constructor, so this saves you some code in the cpp file.
However, if you want to change the constructor behavior in the cpp file, you need to leave out the curly brackets. Otherwise you will get an error like the one you described.