# Input System

## Overview

The **FPS Animation Framework** introduces a standalone input property system. The idea is that you can define custom properties in the **Input Config** asset and then use them in runtime:

<figure><img src="https://784345943-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxcUmJ78NSw1bSUlSO9oP%2Fuploads%2FLM1ZYRnO4WNzlGinr78s%2Fimage.png?alt=media&#x26;token=474dc36c-20b0-441e-b5de-ed679fb934d2" alt="" width="401"><figcaption><p>Example input config asset.</p></figcaption></figure>

Once the game starts, the **User Input Controller** will register all the properties from the **Input Config**, so they can be modified in runtime. So far only 4 types are supported:

* Int
* Float
* Bool
* Vector4

{% hint style="success" %}
**Tip:** floats have an interpolation feature. Set the interpolation speed to something higher than 0, and the system will automatically interpolate the value in realtime. This is a useful function for weights, when you want to smoothly disable/enable some animation features.
{% endhint %}

The framework provides a default **Input Config**, which you can use as a starting point:

<figure><img src="https://784345943-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxcUmJ78NSw1bSUlSO9oP%2Fuploads%2FgXgrqnVN61MNVemUL4RP%2Fimage.png?alt=media&#x26;token=54c1b665-dbb0-4a4e-8b73-e2a98fe1e087" alt="" width="347"><figcaption><p>Default asset.</p></figcaption></figure>

To get or set values in runtime, you can use these methods:

```csharp
// Where T is your custom type.

public virtual T GetValue<T>(int propertyIndex)
public virtual T GetValue<T>(string propertyName)

public virtual void SetValue(string propertyName, object value)
public virtual void SetValue(int propertyIndex, object value)
```

While it is possible to get/set a property by name, it is recommended to use the property index instead. You can get the property index in the **Start()** event like this:

```csharp
private UserInputController _inputController;
private int _myPropertyIndex;

private void Start()
{
    _inputController = GetComponent<UserInputController>();
    _myPropertyIndex = _inputController.GetPropertyIndex("yourPropertyName");
}
```

Now let's learn what parameters control what in the default Input Config.

## Default Properties

### Float properties

* **PlayablesWeight** - controls the weight of the custom animations.&#x20;
* **StabilizationWeight** - controls the stability of the upper body. If set to 1 - fully stabilized, if 0 - overidden locally, stability is not guaranteed.&#x20;
* **LeanInput** - defines the lean angle. Used in the Look Layer.&#x20;
* **Aiming Weight** - controls the weight of the ADS. It is modified in the Ads Layer, and used in the View Layer.
* **TurnOffset** - controls the character rotation offset to counter player rotation (it is used sed for turning in place).

### Bool properties

* **IsAiming** - defines the current state of aiming.&#x20;
* **UseFreeAim** - whether we use the dead-zone mechanic or not. Only used in the Sway Layer.-

### Vector4 properties

* **MouseInput** - defines accumulative mouse look input. X is the yaw rotation, while Y is the pitch rotation. Z and W components are not used. Primarily used by the Look Layer.
* **MouseDeltaInput** - defines the delta mouse look input. X is the yaw delta rotation, while Y is the pitch delta rotation. Only used by the Sway Layer.
* **MoveInput** - defines the current movement input. X represents the horizontal movement, and Y - is horizontal. Used by the Sway Layer.
