> For the complete documentation index, see [llms.txt](https://kinemation.gitbook.io/scriptable-animation-system/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kinemation.gitbook.io/scriptable-animation-system/demo-project/controller.md).

# Controller

The demo project heavily relies on these 3 components:

* FPSController
* FPSMovement
* FPSItem/Weapon

## FPSController

This class is responsible for updating user input for the animation system, changing weapons and calling callbacks on the currently equipped item.&#x20;

The controller iteself does not implement reloading or firing logic, instead, such features are implemented in the **FPSItem** class. You can create custom entities derived directly from the **FPSItem** and override all the important functionality to fit your needs.

Now let's take a look at the **FPSController**'s inspector:

<figure><img src="/files/2KXo4q6nilXSj53K1JP3" alt="" width="416"><figcaption><p>FPSController inspector.</p></figcaption></figure>

{% hint style="success" %}
**Tip:** make sure to add the component to the character root game object. This scripts manually rotates character for turn-in-place feature, so it is crucial that the whole player is rotated.
{% endhint %}

The component does not contain the data itself, instead, it uses an FPSControllerSettings asset. To create such an asset, right click and go to <mark style="background-color:purple;">**Create -> FPS Animator demo -> FPSControllerSettings:**</mark>

<figure><img src="/files/v4Hcs1cv0ZtAglworSvZ" alt="" width="374"><figcaption><p>Controller settings.</p></figcaption></figure>

Specfiy the **Rig Asset**, as we will use it to select bones in the Weapon section. Select the asset we created previously in the [Character Rig](/scriptable-animation-system/workflow/character-rig.md) section.

{% tabs %}
{% tab title="Animation" %}
**Unarmed Profile:** this profile will be used when toggling the unarmed state.

**Turn In Place Angle:** if player exceeds this value, a turn will be performed.

**Turn Curve:** defines how the turn will be applied.&#x20;

**Turn Speed:** the playback of the turning animation.
{% endtab %}

{% tab title="Controller" %}
**Time Scale:** controls the real time scale.

**Equip Delay:** defines the delay time for the next weapon to be equipped.

**Lean Angle:** the max leaning angle in degrees.

**Sensitivity:** mouse input sensitivity scale.
{% endtab %}

{% tab title="Weapon" %}
**WeaponBone**: all weapons will be parented to this element. Just select the IK WeaponBone here.

**Prefabs:** defines all the weapon prefabs the system will spawn when the game starts.
{% endtab %}
{% endtabs %}

As the demo project leverages Unity New Input System, you can find an Input Action asset in the <mark style="background-color:purple;">**Assets/Demo/Settings**</mark> folder:

<figure><img src="/files/8jQbYVvIagkjVjwzYIyz" alt="" width="226"><figcaption><p>PlayerControls.</p></figcaption></figure>

It already has all the important actions, and you can customize it according to your project needs.

{% hint style="danger" %}
**Note 2024-04-26:** the turn-in-place feature has been recently disabled in the demo project. A completely new system is coming soon.
{% endhint %}

## FPSMovement

This script translates the character, controls its speed, pose and movement state:

<figure><img src="/files/mKxntMgJulehuvxUCTXS" alt="" width="381"><figcaption><p>Movement component.</p></figcaption></figure>

Make sure to specify the Movement Settings - they define the speed of each state, smoothing and other locomotion settings:

<figure><img src="/files/GES8rAOZnEIqx8VhEDJH" alt="" width="380"><figcaption><p>Movement settings.</p></figcaption></figure>

**Idle/Prone/Crouching/Walking/Sprinting** are movement states, which only contain the velocity and velocity smoothing properties.

**Crouch Ratio** will be multiplied by the player's standing height. For example, if set to 0.5 the player's height will be decreased twice when crouching.

**Air Friction** defines how controllable our player is when in the air. 1 means 100% controlled, and 0 means no movement input is applied.

**Air Velocity** defines the movement speed multiplier when in air.

**Max Fall Velocity** defines the max vertical velocity.

**Slide Curve** is a delta curve, applied when sliding.

**Slide Direction Smoothing** controls the rotation smoothing when sliding.

**Slide Speed** controls the general velocity when sliding.
