# Faction Asset

## Overview

The **Faction** asset defines the various factions within your game. It includes settings for reputation thresholds, relationships with other factions, and custom variables.

## Creating a New Faction Asset

To create a new **Faction** asset, right-click on the Project Panel and select Create → Game Creator → Factions → Faction.

<div align="left"><figure><img src="https://3895715781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LDchaEIEhpBAh2gCe06%2Fuploads%2Fgit-blob-2c927720a0442941d7106b8350e07ab0793af162%2FScreenshot%202024-06-15%20at%2010.35.51%E2%80%AFPM.png?alt=media" alt="" width="375"><figcaption></figcaption></figure></div>

## Inspector Overview

The **Faction** asset has several distinct sections, each allowing you to configure different aspects of the faction.

The top section includes general information about the ***Faction*** such as its **Name** or a **Description** (if any). It also optionally allows to determine a **Color** and a **Sprite** image used in [UI](https://docs.ninjutsugames.com/game-creator-2/factions/user-interface).

The **Type** field determines whether the ***Faction*** is a *hidden* faction, or a *normal* one.

<div align="left"><figure><img src="https://3895715781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LDchaEIEhpBAh2gCe06%2Fuploads%2Fgit-blob-e43e8ed6242ec12df5b0b10b27dae80f03ea188a%2FScreenshot%202024-06-16%20at%2012.18.35%E2%80%AFAM.png?alt=media" alt="" width="375"><figcaption></figcaption></figure></div>

{% hint style="info" %}
Hidden factions can be hidden from UI elements and are useful for setting up factions that should not be displayed to the user. For example, a player or secret faction.
{% endhint %}

The **Sorting Order** determines the priority of the ***Faction*** compared to the rest, when being displayed as a list on UI elements. A ***Faction*** with a higher value will be displayed above other ***Faction*** assets.

The **ID** is a unique identifier that distinguishes a ***Faction*** from others.

{% hint style="warning" %}
If there are two *Faction* assets with the same **ID** value, an error message will appear above. To resolve it, click on any of the fields and it will reveal a button that regenerates the current value with a unique one.
{% endhint %}

## Reputation Thresholds

The Reputation Thresholds section allows you to define how reputation points translate into faction stances.

{% hint style="info" %}
Reputation points can be disabled in a Faction by disabling "Use Reputation"
{% endhint %}

Each stance is defined by a color and a point threshold, making it easy to visualize the current reputation level in the game.

<div align="left"><figure><img src="https://3895715781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LDchaEIEhpBAh2gCe06%2Fuploads%2Fgit-blob-d61c2c64f67517434c666c714b30dbf801050bdf%2FScreenshot%202024-06-16%20at%2012.19.33%E2%80%AFAM.png?alt=media" alt="" width="375"><figcaption></figcaption></figure></div>

{% hint style="success" %}
Negative values can also be utilized for reputation thresholds.
{% endhint %}

## Faction Relationships

This section allows you to define the default relationships this faction has with other factions.

<div align="left"><figure><img src="https://3895715781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LDchaEIEhpBAh2gCe06%2Fuploads%2Fgit-blob-092ed02808823998c73f5392b8216f385f9f189d%2FScreenshot%202024-06-16%20at%2012.20.00%E2%80%AFAM.png?alt=media" alt="" width="375"><figcaption></figcaption></figure></div>

{% hint style="success" %}
You can click on each circle to change **relationship** towards the specific **Faction**
{% endhint %}

## Faction Variables

Custom variables can be defined on factions. These variables can be used in gameplay to store faction-specific data.

Faction Variables allow you to define custom data specific to each faction. These variables work similarly to Global Name Variables, but with a **key distinction**: all factions have the same set of variables, but each faction can hold different values for these variables.

<div align="left"><figure><img src="https://3895715781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LDchaEIEhpBAh2gCe06%2Fuploads%2Fgit-blob-b692e1b5713b99acdd0f8a20899730165e753064%2FScreenshot%202024-06-16%20at%2012.20.19%E2%80%AFAM.png?alt=media" alt="" width="375"><figcaption></figcaption></figure></div>

{% hint style="success" %}
For example, if you define a variable called resourceLevel, every faction will have this variable, but the resourceLevel value can be different for each faction. This allows you to track and manage faction-specific data dynamically.
{% endhint %}

By using Faction Variables, you can create a rich, dynamic environment where each faction’s unique state can influence the overall gameplay experience.

## Save & Load

**Variables** and **Relationships** can be saved between play sessions to later be restored when loading a game. Disabling the *save* option will make all variables keep the initial value as their starting value, even after loading a previously saved game.

<figure><img src="https://3895715781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LDchaEIEhpBAh2gCe06%2Fuploads%2Fgit-blob-d5eef6bf1dccd9ef622690954a3bfc4001f42905%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>
