Take for example the following scenario:
You are making an RPG where you have several entity types roaming your world; monsters and humans for example. Monsters would be well suited to the APawn class as their supertype, while humans would be a natural fit for ACharacter. Unfortunately, they both need to get assigned a level, hitpoints, and their associated logic.
The obvious course of action is to create a superclass (say, ARpgEntity) for both that implements this logic to be used by both. Unfortunately, UE4 does not seem to support multiple inheritance in actors, so you can’t have a class that is both an ACharacter and an ARpgEntity.
How would you tackle a situation such as this instead?
As an aside, I am aware of the fact that APawn is a superclass of the ACharacter, and it would make sense to make the ARpgEntity class a pawn to function as a superclass for a character, but it would seem to me that it would also require implementing all ACharacter functionality yourself.
As you already said yourself, Pawn is already a superclass of Character. So there is one big similarity right there.
From my experience, having AI pawns that inherit from Character is not a big problem, maybe it’s even convenient, with the character movement and all.
In my current project, I have a CharacterBase that inherits from Character and implements base functionality like HP, inventory, etc. Then I have an AI subclass that runs a behavior tree, and a Player subclass that is to be controlled by players. Most of the logic is in the base class, so if I choose I want to make AI controllable by the player, it’s not a big deal really.
In my opinion, you shouldn’t make your AI inherit from pawn (or some selfmade subclass) only… And inheriting both pawn (or a subclass) and character doesn’t make sense either, because of the already existing inheritance…
Hope I could help with my input.
So inheriting, say, an ADragon class from a hypothetical ABaseCharacter shouldn’t give issues with its non-character-like behaviour, as ACharacter inherits from APawn? If I understood your point correctly.
If you want the dragon to be controllable by an AIController or a player maybe even, and it should be able to walk around and be animated, I’d shorthand definitely go for inheriting from a character.
If your BaseCharacter has too much “character-like” behaviour for a dragon, you might just want to put another base class in between, have your dragon inherit it, have another BaseCharacter inherit it, and then make subclasses from that for humanoid (NPC, player).
You’ll have to find your own preference for this. I’d definitely recommend the character as it already has basic movement set up in the movement component, and it’s just easier to get started. See the documentation on characters to get a better feeling on it.
EDIT: If you inherit from a pawn only, in the long run, you’ll most likely have to reimplement many things that the character has already implemented (starting with basic things like changing max movement speed also in diagonal movement, of course this is an easy to solve example, but it might sum up to a lot). IMO things that work similarly for the both of them should be put in a BaseCharacter and have everything else inherit from it. If there are exceptions, the performance hit or overhead will be small.