Hello, newbie here who needs help on a design decision.
I’m planning on a game that uses both Characters and Creatures, and currently my approach is inheriting common functionality from a parent Pawn class. I would like to do things like “Detect MyPawn Capsule Overlap → MyPawn virtual DoDamage() → Child’s DoDamage() override”
However, since there’s no multiple inheritance option for a custom AMyCharacter to inherit from both AMyPawn and ACharacter, what would the best approach be? So far I think my options are:
1- Copy-paste (and tweak) the ACharacter class into AMyCharacter, inherit from AMyPawn. EDIT: And ACharacterMovementComponent, since it expects ACharacter in a few places.
2- AMyCharacter inherits from ACharacter and uses Interfaces/ActorComponents for characters and creatures.
3- (least-desired) Modify engine source for ACharacter
…Or am I overlooking the obvious? Thanks in advance.
I think you are overlooking the obvious. However, in order to help, please provide a better description of the actors to be used, show us the hierarchy. It is difficult to understand what the different classes you brought up were and what inheritance they have.
In order to give the best description, please describe them a bit more!
this is an extremely vague description and i dont really see what the problem is, to answer your question, i think what you want to do is make a pawn class, have all events and variables that both creatures and characters will ahve in there. then make a child class for a character, then one for a creature, with more specific varialbes and events in them. Then continue making child blueprints off of those two. interfaces are a little different in unreal than standard coding, their used more for blueprint communication than anything else, but if there is more functionality that for some reason you cant put in the parent class and numerous blueprints will use them, you can use an interface for that