A pawn class for both Character and NPC(Enemy)?

Hi,

I was wondering what design is appropriate when the Character and NPC holds similar state and functions? Like a human player and a human NPC? Also for different NPCs, do you keep creating new classes? It will sure be a waste of time for writing same code.

My first thought is using multiple inheritance like the code below but it seems impossible in Unreal.

class AMyPlayer : public AMypawn, ACharacter 

Could anyone suggest what is the right way to do it? Is Component an option? Or interface?

Many Thanks!!!

if many characters behave the same, they should be separate skins, rather than separate characters.

a Skateboarder and a Soldier might be different characters, because they control very differently, but James Bond and Solid Snake can be Structs read from a DataTable that initialize a Soldier character with the proper skin and stats.

you only need to code new actors when you want something functionally different. if actors are only different in appearance, their differences should be encapsulated in data structures, which initialize the state of the actor.

some ControllerInput functionality can also be put in these Skin data structures, like the MoveSet and FrameData in fighting games.

the goal is to allow designers to create new characters with as little coding as possible, just by editing data in spreadsheets, and selecting the mesh/animations they imported.


AI Bots usually keep their state in a Blackboard DataAsset and make decisions with a Behavior tree, created by an AIController, using AIController functions like MoveTo, on a NavMesh.

Thanks for the answer! I seem to understand what you mean but not too clear. I get what you mean by difference of appearance and controller.

About this sentence “You only need to code new actors when you want something functionally different”. Then when you code new actors, is it right to first code a base actor and then derive it?

Say, a Creature character class and then being derived by Human character class and Dragon character class?

Thanks!

listen to this presentation by a programmer from God Of War, its kinda long, but worth hearing. (maybe jump 21 minutes in) part of it covers how they added capabilities for both their players and enemies, and how they tried to make the designers and animators do most of the work. instead of programming alot of unique scenarios, they just made it flexible and data driven.


you can derive from a base class, but dragons and creatures should probably be Pawns rather than Characters, because you probably want more control over their root collision component.

Thanks, the video helps a lot!