So I’m transitioning from a Unity mindset to an Unreal mindset with development and would like to know if I’m on the right path.
After fumbling around with blueprints, I’ve found them to be pretty fun to use, but I keep hitting roadblocks and needing to superclass them in C++. This led me to think maybe I should always use C++ superclasses and only reference them instead of the overridden blueprint classes, which basically leaves blueprints for overriding default values, adding components, and implementing specialized behaviors.
I haven’t tested this very thoroughly, though, so I’m not even sure how robust it will be, or if it even works as I expect. Before I get too deep and make this my standard, I’m wondering if anyone has different ideas/practices that might work better.
The example I’m working with is an RTS. It would probably be easiest to visualize with the pseudocode:
class Faction {
// These are all initialized in the constructor using iterators for their c++ class
TArray<VesselUnit *> Vessels;
TArray<StructureUnit *> Structures;
TArray<AddonUnit *> Addons;
}
class Hubert_Faction : Faction {
}
//...
class UnitBaseClass {
UStaticMesh *mesh
}
class VesselUnit : UnitBaseClass {
}
class Fighter : VesselUnit {
}
class Tank : VesselUnit {
}
Then I can create a Hubert_Faction_BP blueprint, add some Hubert_Fighter_BP and Hubert_Tank_BP child actor components with their static meshes set, and I can easily use class iterators within C++ or within Blueprints.
So far, this seems to have several benefits.
- IMO, It presents a cleaner class/blueprint hierarchy than just a bunch of base classes.
- If I need a virtual method that can be overridden by blueprints, I use UFUNCTION(BlueprintNativeEvent), and it’s easily callable in C++.
- If I need to implement a simple algorithm, I jump back to the code and quickly implement one instead of having to mess with the spaghetti of blueprints.
- I can easily iterate all actors using the C++ class iterators.
I’m interested to know if anyone sees any critical caveats with this that will present a brick wall down the road.