Hi to all of you
I’m currently working on some kind of RTS game. In this game, as you can imagine, there are buildings (AActors as simply as it can be) and ships (ACharacters for pathfinding, networking, etc.) and others elements but their are not important.
But my project was made in pure blueprint. But now I decided to switch to c++ and I met a problem. In ABuilding and AShip there are a lot of similar code such as meshes, health systems and other and other and I decided to make a ABase class which will hold code for those similarities. So I made like this: 1) ABase : public AActor - base class with most common code
2) ABuilding : public ABase - class for buildings, inherits from ABase
3) AShip : public ABase, public ACharacter - class for ships, the problem place, AShip should have not only properties as building but also capsule and pathfinding
I know that UE4 doesn’t support multiple inheritance nad I’m asking for advice what should I do. I found some solutions:
- Use Interface. But interface wouldn’t help with copying code in ABuilding and AShip when I will be writig implementation of a virtual methods
- Just rid off from ABase and use ABuilding and AShip. The problem is similar to (1)