> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kinemation.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Procedural Animation: Dynamic Bone Modifiers in CAS

> Procedural Animation component in CAS runs modular Animation Modifiers that alter bone transforms after blending — for foot IK, weapon sway, and recoil.

The **Procedural Animation component** runs after Layered Blending has produced a combined pose. It applies a stack of modular **Animation Modifiers** — each one a ScriptableObject — that read the current bone transforms and write new ones. Modifiers can solve foot IK, apply weapon sway, drive recoil, attach hands to surfaces, and more. Because they are modular ScriptableObjects, you can mix, reorder, and reuse them across different characters and weapon profiles without duplicating any code.

## What the Component Does

The Procedural Animation component has three responsibilities:

1. **Create** — at startup it instantiates each modifier in the active Procedural Animation Settings asset, giving modifiers a chance to cache bone references and allocate any state they need.
2. **Update** — each frame it calls every modifier in order, passing the current pose so each modifier can read and alter bone transforms.
3. **Dispose** — when the settings change or the component is destroyed, it tears down active modifiers cleanly, releasing any unmanaged resources they hold.

Because creation and disposal are managed automatically, you never need to call lifecycle methods on modifiers directly — configure the settings asset and let the component handle the rest.

## Procedural Animation Settings (PAS) Asset

All modifiers are stored in a **Procedural Animation Settings** asset. Think of this asset as a profile: one PAS asset per weapon or gameplay state, each containing the exact set of modifiers that make sense for that context.

### Creating a PAS Asset

<Steps>
  <Step title="Open the Project window">
    Navigate to the folder where you want to store the settings.
  </Step>

  <Step title="Create the asset">
    Right-click and select **Create ▸ KINEMATION ▸ CAS ▸ Procedural Animation**.
  </Step>

  <Step title="Assign it to Character Animation Settings">
    Open the **Character Animation Settings** asset for the relevant weapon or state and drag the new PAS asset into the **Procedural Settings** field.
  </Step>
</Steps>

<Tip>
  You can share a single PAS asset between multiple Character Animation Settings profiles if the same modifier stack applies to several weapons. For example, a `PAS_Unarmed` asset might be shared across all bare-hand gameplay states.
</Tip>

## Modifier Order Matters

Modifiers are applied to the pose sequentially in the order they appear in the PAS asset. This means the output of one modifier becomes the input of the next. For example:

* A **foot IK modifier** should run before a **leg bend modifier** so that the IK target position is correct when the knee bending is solved.
* A **weapon sway modifier** should run before a **hand attachment modifier** so that the swayed weapon position is what the hands lock onto.

Always consider the dependencies between modifiers when you arrange the stack. If you see unexpected results, reordering the modifier list is often the first thing to try.

<Warning>
  Changing modifier order at runtime is not supported. Configure the order in the PAS asset before entering Play mode.
</Warning>

## Adding a New Modifier

<Steps>
  <Step title="Select the PAS asset">
    Click on the Procedural Animation Settings asset in the Project window to open it in the Inspector.
  </Step>

  <Step title="Click Add Animation Modifier">
    Click the **Add Animation Modifier** button at the bottom of the Inspector.
  </Step>

  <Step title="Browse the categories">
    A categorised menu appears listing all available modifier types. Navigate the categories to find the modifier you need — for example, **IK > Foot IK** or **Physics > Weapon Sway**.
  </Step>

  <Step title="Configure the new modifier">
    The modifier appears at the bottom of the list. Expand it to configure its properties. Drag it up or down in the list to set its position in the execution order.
  </Step>
</Steps>

## Modifier Reference

Each individual modifier has its own set of properties and behaviours. For a full reference of every built-in modifier, its configuration options, and usage examples, see the **Animation Modifiers** section of the CAS documentation.

<Note>
  CAS is designed to be extended. You can author custom Animation Modifiers by creating a new ScriptableObject that inherits from the CAS modifier base class. Once registered, your custom modifier appears in the **Add Animation Modifier** menu alongside the built-in ones.
</Note>
