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

**URL:** <https://forums.unrealengine.com/t/a-pawn-class-for-both-character-and-npc-enemy/353939>\
**Category:** Character & Animation\
**Tags:** share, unreal-engine, pawn, CPP, question\
**Created:** [April 12, 2016, 7:51pm UTC](https://forums.unrealengine.com/t/a-pawn-class-for-both-character-and-npc-enemy/353939 "2016-04-12T19:51:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bwhhy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@bwhhy](https://forums.unrealengine.com/u/bwhhy)\
**Post date:** [April 12, 2016, 7:51pm UTC](https://forums.unrealengine.com/t/a-pawn-class-for-both-character-and-npc-enemy/353939/1 "2016-04-12T19:51:17Z")

</div>

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!!!

---

<div class="post-metadata">

**Author:** ![ScottSpadea](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/scottspadea/32/1194682_2.png) [@ScottSpadea](https://forums.unrealengine.com/u/ScottSpadea)\
**Post date:** [April 12, 2016, 10:03pm UTC](https://forums.unrealengine.com/t/a-pawn-class-for-both-character-and-npc-enemy/353939/2 "2016-04-12T22:03:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bwhhy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@bwhhy](https://forums.unrealengine.com/u/bwhhy)\
**Post date:** [April 12, 2016, 11:44pm UTC](https://forums.unrealengine.com/t/a-pawn-class-for-both-character-and-npc-enemy/353939/3 "2016-04-12T23:44:31Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![ScottSpadea](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/scottspadea/32/1194682_2.png) [@ScottSpadea](https://forums.unrealengine.com/u/ScottSpadea)\
**Post date:** [April 13, 2016, 3:28am UTC](https://forums.unrealengine.com/t/a-pawn-class-for-both-character-and-npc-enemy/353939/4 "2016-04-13T03:28:35Z")

</div>

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.

> **[God of War: How the Left and Right Brain Learned to Love One Another](https://www.gdcvault.com/play/1013327/God-of-War-How-the)**
>
> God of War is a big game, lots of special case elements, high production values. Its lead designer was a Right Brain, random creative type who couldnt really speak Programmer. Its lead programmer was a Left Brain analytical type who likes things...

* * *

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.

---

<div class="post-metadata">

**Author:** ![bwhhy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@bwhhy](https://forums.unrealengine.com/u/bwhhy)\
**Post date:** [April 13, 2016, 11:51am UTC](https://forums.unrealengine.com/t/a-pawn-class-for-both-character-and-npc-enemy/353939/5 "2016-04-13T11:51:01Z")

</div>

Thanks, the video helps a lot!
