# Layers and animator

## Step 1 - Add layer references

There're 2 ways to modify procedural animation in runtime:

* Modifying layers directly
* Using animator curves

In this step we will focus on how to work with animation layers in runtime. First off, add references to the layers you want to modify based on your project requirements.

**Example**

{% code title="FPSController.cs" overflow="wrap" %}

```csharp
[SerializeField] [HideInInspector] private LookLayer lookLayer;
[SerializeField] [HideInInspector] private AdsLayer adsLayer;
[SerializeField] [HideInInspector] private SwayLayer swayLayer;
[SerializeField] [HideInInspector] private LocomotionLayer locoLayer;
[SerializeField] [HideInInspector] private SlotLayer slotLayer;
```

{% endcode %}

In this case, we've added 5 references to the layers we will later use in the code. To assign the references, we will use this code snippet:

<pre class="language-csharp" data-title="FPSController.cs" data-overflow="wrap"><code class="lang-csharp">private void InitLayers()
{
<strong>    InitAnimController(UpdateCameraRotation);
</strong>    
    controller = GetComponentInChildren&#x3C;CharacterController>();
    animator = GetComponentInChildren&#x3C;Animator>();
    
    // Gettings layer component references
    lookLayer = GetComponentInChildren&#x3C;LookLayer>();
    adsLayer = GetComponentInChildren&#x3C;AdsLayer>();
    locoLayer = GetComponentInChildren&#x3C;LocomotionLayer>();
    swayLayer = GetComponentInChildren&#x3C;SwayLayer>();
    slotLayer = GetComponentInChildren&#x3C;SlotLayer>();
}
</code></pre>

Here's an example how layers can be used in the main Update loop:

```csharp
private void SprintPressed()
{
    //... SprintPressed() implementation
    lookLayer.SetLayerAlpha(0.5f);
    adsLayer.SetLayerAlpha(0f);
    locoLayer.SetReadyWeight(0f);
    //... SprintPressed() implementation
}
```

In this example we call the SetLayerAlpha(float alpha) method, which is a base method for all animation layers. Every animation layer has its own unique method and properties, see more in [Animation Layers](/fps-animation-framework/fundamentals/animation-layers.md).

## Step 2 - Add animator curves

### Control curves

Another important part of the animation setup is Animator Controller and curve parameters. You've probably noticed that all animation layers have this property:

<figure><img src="/files/J3JxQRQBCV0Rrxw6UpKp" alt="" width="327"><figcaption><p>Every animation has this property</p></figcaption></figure>

What is this? The property defines the name of the float parameter of your Animator Controller, which will be used to control the weight of the layer.

For example, if the curve value is 1, then the layer is fully applied, if it's 0 - the layer is disabled.

{% hint style="warning" %}
**Tip:** this is default behavior, Look Layer and Left Hand IK Layer use inverse blending: if the value is 1, the layer is disabled, and if it's 0 - fully applied. These curves are called Masks in the framework.
{% endhint %}

By default, there're only 2 curves that drive the animation layer blending:

* **SprintWeight** - controls the animation system weight. If character is sprinting - the upper body is no longer overidden by the system. Attached to all sprinting motions. Used in [Locomotion Layer](/fps-animation-framework/fundamentals/animation-layers/locomotion-layer.md).
* **MaskLeftHandIK** - controls the left hand IK weight. When 1, layer is disabled. Attached to some sprinting animations that do not need left hand IK. Used in [Left Hand IK Layer](/fps-animation-framework/fundamentals/animation-layers/left-hand-ik-layer.md).
* SprintPoseWeight - controls the sprinting pose. If one - sprint pose is enabled, if 0 - disabled. Used by the [Locomotion Layer](/fps-animation-framework/fundamentals/animation-layers/locomotion-layer.md).

Simply add these curves to your animator:

<figure><img src="/files/G9mAMESWySF5e81oCWeE" alt=""><figcaption><p>Add new float parameters</p></figcaption></figure>

### IK Curves

This is another type of curves, primarily used for procedural animations:

<figure><img src="/files/8MrzT4Rnh84NyPYZUYHc" alt="" width="212"><figcaption><p>R stands for rotation, T - for translation</p></figcaption></figure>

Each curve define movement for every rotation and translation axis. This offset will be applied to the Master IK object (just like weapon sway or recoil). Used in [Locomotion Layer](/fps-animation-framework/fundamentals/animation-layers/locomotion-layer.md).

The demo Animator Controller has a layer for procedural animations:

<figure><img src="/files/QH0cOzNBc2VEc59HIqF9" alt="" width="563"><figcaption></figcaption></figure>

This is useful when you need to apply some procedural offset to the arms for a specific motion.

**For example**, let's say we want to move the arms slightly backwards when landing animation is played. We need to only add one single curve **IK\_T\_Z** and animate it for our clip:

<figure><img src="/files/HOC6H6WbuD49T7vh8qPY" alt="" width="563"><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kinemation.gitbook.io/fps-animation-framework/tutorial/integration/layers-and-animator.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
