> ## 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.

# Animation Modifiers: Procedural Bone Control in CAS

> Animation Modifiers in CAS adjust bones procedurally at runtime — enabling IK, aiming, look rotation, and dynamic effects without extra animation clips.

Animation Modifiers are the procedural layer of the Character Animation System. Each modifier runs after the base animation pose is evaluated and directly adjusts selected bones at runtime — letting you add dynamic behaviour that would be impractical or impossible to author as fixed animation clips. Common examples include rotating the spine to follow an aim direction, aligning feet to uneven terrain, applying recoil offsets, or distributing look-rotation across the upper body.

## Where Modifiers Live

You configure modifiers in the **Procedural Animation Settings** asset, where they appear as an ordered list. You can add multiple modifiers of the same type to the same settings asset — for example, two separate **Two Bone IK** modifiers for the left and right arms.

Each entry in the list has a **Gizmo-toggle** button that shows or hides the modifier's scene widget, and a **visibility icon** that enables or disables the modifier entirely. Both controls are useful during setup and debugging.

<Tip>
  Modifiers are applied at runtime in the exact order they appear in the list. Place upstream modifiers (such as **Copy Bone** or **Foot IK**) before downstream ones (such as **Two Bone IK**) that depend on their output.
</Tip>

## Two-Part Architecture

Every modifier is composed of two distinct pieces:

<Steps>
  <Step title="Settings (ScriptableObject)">
    A `ScriptableObject`-derived class that stores inspector-editable data — bone references, angle limits, smoothing speeds, and so on. By default, modifier settings live embedded in the Procedural Animation Settings asset and are not exposed as standalone project assets.
  </Step>

  <Step title="Animation Job (struct)">
    A struct that implements the actual runtime logic via Unity's Playables API. The job runs on the animation thread, so you should never mutate its internal fields directly from the main thread — use the provided `UpdateJobData` callback path instead.
  </Step>
</Steps>

### AnimationModifierSettings Base Class

All built-in modifier settings inherit from `AnimationModifierSettings`:

```csharp theme={null}
public class AnimationModifierSettings : ScriptableObject, IRigProvider, IBindableContext
```

<ParamField path="characterPrefab" type="GameObject">
  Reference to the player or character prefab. Required so editor widgets can resolve the skeleton hierarchy.
</ParamField>

<ParamField path="alpha" type="float" default="1">
  Global influence multiplier for this modifier, clamped to `[0, 1]`. Set to `0` to fully disable the modifier's effect without removing it from the stack.
</ParamField>

<ParamField path="weightOverrides" type="List<WeightOverride>">
  Additional runtime float parameters that further modulate the final influence. Multiple overrides are **multiplied** together, so a single zero override zeroes the whole modifier. See [Weight Overrides](#weight-overrides) below.
</ParamField>

Key virtual methods you can override when creating a custom modifier:

| Method                 | Description                                                       |
| ---------------------- | ----------------------------------------------------------------- |
| `InitializeOnLoad()`   | Called on game start. Build Property Bindings here.               |
| `CreateAnimationJob()` | Returns the `IAnimationModifierJob` instance that runs the logic. |
| `GetContext()`         | Returns the context `GameObject` for Property Bindings.           |
| `GetHierarchy()`       | Returns the full skeleton bone array.                             |

## Weight Overrides

Weight Overrides give you fine-grained per-modifier influence control driven by arbitrary float properties — for example, blending a modifier out when a specific animation state is active.

<ParamField path="Weight" type="float property binding">
  A bound float that controls how much this override contributes. Connect it to any float value in your project via Property Bindings.
</ParamField>

<ParamField path="Is Mask" type="bool" default="false">
  When enabled, the override's contribution is computed as `1f - Weight`, effectively inverting it. Useful for "disable when active" patterns.
</ParamField>

<ParamField path="In Range Min / Max" type="float" default="0 / 1">
  Remaps the incoming Weight value from an arbitrary range into `[0, 1]`. If your source value lives in a different range (e.g., `[0, 100]`), set Min to `0` and Max to `100`.
</ParamField>

<Tip>
  You can attach multiple Weight Overrides to the same modifier. Their computed values are multiplied together — if any single override evaluates to zero, the entire modifier is suppressed.
</Tip>

## The IAnimationModifierJob Interface

Every Animation Job struct implements `IAnimationModifierJob` in addition to Unity's `IAnimationJob`. The interface defines the following lifecycle methods:

```csharp theme={null}
public interface IAnimationModifierJob
{
    // Called on the main thread when a new profile is linked.
    void Initialize(ModifierJobData jobData, AnimationModifierSettings settings);

    // Creates the AnimationScriptPlayable that wraps this job.
    AnimationScriptPlayable CreatePlayable(PlayableGraph graph);

    // Returns the associated modifier settings.
    AnimationModifierSettings GetModifierSettings();

    // Main-thread update — push new data into the playable here.
    void UpdateJobData(AnimationScriptPlayable playable, float weight);

    // Called after the pose is finalised each frame.
    void LateUpdate();

    // Releases native collections and playable resources.
    void Dispose();

    // Draws scene gizmos for this modifier.
    void OnDrawGizmos();
}
```

<Warning>
  Animation Jobs execute on the **animation thread**. Never write to job struct fields from outside `UpdateJobData` — doing so can produce race conditions and unpredictable pose results.
</Warning>

## Modifier Pooling

CAS reuses already-allocated modifier jobs when the active Procedural Animation Settings change (for example, when swapping profiles at runtime). On reuse, the system calls `Initialize()` again and recreates the `AnimationScriptPlayable` linked to that job. You do not need to manually manage this lifecycle.

## Built-in Modifiers

<CardGroup cols={2}>
  <Card title="Aim At" href="/cas/modifiers/aim-at" icon="crosshairs">
    Rotates a bone or chain to point at a world-space target. Ideal for head tracking, spine aiming, and weapon direction.
  </Card>

  <Card title="Foot IK" href="/cas/modifiers/foot-ik" icon="shoe-prints">
    Raycasts beneath feet to keep them planted on uneven terrain. Works with Two Bone IK for full leg correction.
  </Card>

  <Card title="Full Body IK" href="/cas/modifiers/full-body-ik" icon="person">
    Applies IK to all four limbs simultaneously with a single modifier — hands, feet, and elbows/knees in one pass.
  </Card>

  <Card title="Two Bone IK" href="/cas/modifiers/two-bone-ik" icon="hand">
    Solves a two-bone chain (arm or leg) to reach a target position. The foundation for hand and foot IK setups.
  </Card>

  <Card title="Look Modifier" href="/cas/modifiers/look-modifier" icon="eye">
    Distributes pitch, yaw, and roll rotation across spine bones. Includes built-in turn-in-place support.
  </Card>

  <Card title="Copy & Modify Bone" href="/cas/modifiers/copy-bone" icon="copy">
    Transfers bone transforms between bones (Copy Bone) or applies position/rotation offsets to one bone or a chain.
  </Card>

  <Card title="Dynamic Bones" href="/cas/modifiers/dynamic-bones" icon="link">
    Animates a bone in one skeleton space and applies it in another — essential for weapon positioning and left-hand IK.
  </Card>

  <Card title="State Behaviours" href="/cas/modifiers/state-behaviours" icon="diagram-project">
    Animator Controller state components that trigger CAS events — smooth float transitions and procedural step playback.
  </Card>
</CardGroup>
