All classes from Class_3.1 to Class_3.10 inherit from the same Class_3.
When I change something in Class_1 I experience a very long compilation time (~25s). When I delete all the classes from 3.1 to 3.10 the compilation time is much faster (~8s). I assume that the compilation is slow because there is a lot of classes at the end of the inheritance chain and the compiler has to build the Class_1 (which is pretty big) for each child class.
Is there a way to improve the BP compilation time without changing the inheritance chain?
I have already moved some of the logic of Class_1 to C++ which helped a little bit but not as much as I would like to. The classes from 3.1 to 3.10 have almost no logic inside. I am using them to override properties from base classes.
Is it true that even if child classes store very little logic, a large number of inheritances may cause a bottleneck in terms of compilation time of the base class?
What is the practical use case for this? I cannot think of a scenario where implementing this type of ‘inheritance’ is the best way to solve a real world problem.
This kind of inheritance structure is actually fairly common.
For example, the weapon system in Unreal Tournament 3 was implemented in this way:
Actor < InventoryItem < Weapon
Weapon < Shock Rifle
Weapon < Sniper Rifle
Weapon < Rocket Launcher
etc.
I’d argue that with Blueprints it should even be more common as Blueprints allow an easy way to parameterise class data (decoupled from the behaviour). Unfortunately as far as I know there’s not much you can do to speed this up other than moving your logic to C++.
These are all examples of a straight forward inheritance. I still do not see any problems with compilation time? Even in this example, it’s not like you’re going to need to modify Actor class anyway, so any changes in Weapon only have one layer to propagate. This happens nearly instantly, what takes you 25 seconds to compile?
If I delete everything behind Bad_AI_Dude, the compilation of BaseWarrior is faster. This is weird because most of these AI classes have no logic inside.
I looked into engine source code and tried to debug the BP compilation process but this didn’t give me much. I think that the “Reinstance” step ([described here][2]) takes the most time but I don’t know why.