Skip to content

Factions

Factions are represented by Primary Data Assets based on the UNinjaFactionDataAsset class. They were built on top of Unreal Engine's Teams, which is commonly used by AI Agents to determine their attitude towards other pawns.

To create a Faction you can either create an usual Data Asset using the class above as the base or you can create Factions from the dedicated option in the Content Browser's Contextual Menu.

Faction Data

A Faction is defined by the following attributes:

Attrbute Description
Display Name Friendly name used to represent this faction.
Faction Tag Unique Gameplay Tag used to identify this faction.
Team Id A numeric ID used by Unreal Engine's Team System.
Color Color used to represent this faction in UI elements, if applicable.
Tags Any additional tags used to add characteristics to this faction.
Default Attitude Towards My Faction Default Attitude towards members of the same faction.
Default Attttude Towards Other Factions Default Attitude towards members of other factions.
Attitude Matrix Specific Attitudes not covered by the attributes above.

Let's create a few factions as an example. Create their Data Assets and fill their values as follows.

Create your factions in the same folder

If you are using the provided Database, it will be much easier to configure it if your Faction Data Assets are in the same folder.

Player Faction

Enemy Faction

Enemy Faction

Wildlife Faction

Same Team IDs, different Factions

Within the Faction System, a Faction is uniquely identified by its Faction Tag!

Team IDs are used by Unreal to define different Teams. You may choose to group multiple factions, with different tags under the same category and have Unreal consider them as the same Team.

Custom Attitudes

As mentioned in the list of Faction Attributes, you can have a more granular control for attitudes between different factions. Remember, within the Faction System, Factions are identified by their unique Faction Tags, so this is what drives this custom table.

Custom Attributes will require the Target Faction Tag and the Attitude value.

To create custom attitudes, go ahead and create a new Data Table using the `FactionAlignmentTableRow" struct. For this example, let's create a custom Attitude for Enemies and Merchants.

Enemies will be neutral towards wildlife and merchants will be hostile to enemies.

Enemy Attitude

Merchant Attitude

Group multiple exceptions in the same entry

Please note that for the Custom Attitude Table, you may provide multiple Faction Tags to the same row, since it's actually using a Gameplay Tag Container. This means that you can group your custom attitudes based on the attitude itself.

With these tables completed, go back to your Enemy Faction Data and add the custom Attitude Table to the Attitude Matrix. Do the same to the Merchan Faction Data. Once that's done, they should look like this.

Enemy Faction

Enemy Faction

Next Steps

Here's a summary of what we have so far:

  1. A Faction for Players, that is Friendly towards themselves and Neutral towards others.
  2. A Faction for Enemies, that is Friendly towards themselves and Hostile towards others, except for the Wildlife Faction, to which they are Neutral.
  3. A Faction for Merchants, that is Friendly towards themselves and Neutral towards others, except for the Enemy Faction, to which they are Hostile.
  4. A Faction for Wildlife, that is Neutral towards themselves and others.

The next steps are to register these Factions with the Faction Database and then grant Membership to its Members.