I am trying to move from blueprints into c++ and have been rolling through the tutorials. I’ve been able to work through some of the misstatements and small outdated things, but for the life of me I can’t figure out the error with this block:
void AMyActor::PostInitProperties() // error here with 'PostInitProperties()
{ // Error: inherited member is not allowed
Super::PostInitProperties();
DamagePerSecond = TotalDamage / DamageTimeInSeconds;
}
I have a basic understanding of inheritance, but I can’t seem to figure out where this goes. Everything works without it no problem. I’ve searched for answers and scrounged the documentation, but can’t quite wrap my head around where it needs to go.
Sure! I will start with my problem that I had. There is a class in the UE4 source code pre made with default values I want to call to do a specific job. I put the call in my source file, but it errors because it can’t see it. I have to copy the class somewhere for it to use, which is why I got the error. By putting ‘virtual void PostInitProperties();’ in my header under ‘public:’, it’s like making an object of the class for my actor to use exclusively that I can then call and reference with ‘super’ to my every need. It’s more complicated than that, but that’s the just of it. I’m still learning and getting my hands dirty, but this is object orientation and inheritance.
There can be several different ways to do the same thing, and their codebase is constantly evolving as is their standards, so I hadn’t looked at that specific case in a long while as I have been dealing mostly with blueprints while I’m prototyping. Given I now realize what you mean I apologize, but it can work without that as well.
Putting virtual void PostInitProperties(); directly under public: is the difference between this solution working and not working. Thanks for clarifying!