> For the complete documentation index, see [llms.txt](https://malbersanimations.gitbook.io/animal-controller/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://malbersanimations.gitbook.io/animal-controller/secondary-components/ik-manager/weight-processors.md).

# Weight Processors

Decide when an IK Set is allowed to work

## Overview

An IK Set says *what* the IK does. **Weight Processors** say *when*.

They sit on the **Weight Processors** tab of an IK Set and form a chain. Each one looks at some piece of game state — an animation curve, the aim angle, the active State, whether the Aimer has a target — and returns a multiplier. Everything is multiplied together into the Set's **Final Weight**.

```
  IK Set Weight  ×  Global Weight
      ×  Weight Processor 1
      ×  Weight Processor 2  …   =   Final Weight
```

The chain short-circuits: the moment the running weight hits `0` the remaining processors and every solver in the Set are skipped, so a gated-off Set costs almost nothing.

This is what lets an IK Set be permanently enabled and still behave: the bow-aim IK stays on all the time, and the Weight Processors take it to zero the instant the character enters the water or plays a Mode.

***

## Using them

Add one with the **+** of the Weight Processors list, then pick a type from the dropdown. Each row has four controls:

| Control           | Meaning                                                                                 |
| ----------------- | --------------------------------------------------------------------------------------- |
| **Toggle** (left) | Active. An inactive processor is skipped entirely, as if it were not there.             |
| **Name**          | Generated from the processor's own settings, so the list reads as a summary.            |
| **⚠ icon**        | **Invert**. The result becomes `1 - result`. The row title gets an *(Inverted)* suffix. |
| **🗑 icon**       | Clears the slot.                                                                        |

{% hint style="info" %}
**Order matters.** *Animator Parameter (Float)* and *Look-At Range* clamp against the weight coming into them, so put them near the top of the list. The state-based ones (State, Mode, Stance, Conditions) are pure on/off gates and can go anywhere.
{% endhint %}

{% hint style="success" %}
In Play Mode the Set shows a read-only **Final Weight** at the top of the tab. Watch it while you toggle things — it is the fastest way to find the processor holding a Set at zero.
{% endhint %}

***

## Animator Parameter (Float)

Drives the weight from a float Animator parameter — in practice, from a curve authored inside an animation clip. The most precise gate available, because the IK fades exactly with the animation instead of guessing.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FM3u8ROIjgdQ5F8XlOLxP%2Fimage.png?alt=media&#x26;token=3718e5bb-3921-46f0-8062-b4c09db40e03" alt="" width="498"><figcaption></figcaption></figure>

### How to use it

Add a curve to the animation clip and name it after the parameter. Unity turns clip curves into float Animator parameters automatically.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2Fz0wGDlkz0nF3WHIkQTQ0%2FUnity_5N5yETnD5E.gif?alt=media&#x26;token=02b56a92-c1d9-41c1-b2e3-d7cceb525c8e" alt="" width="552"><figcaption><p>A curve named 'IKFreeHand' authored in the clip, controlling the weight of the IK that pins the support hand to the weapon.</p></figcaption></figure>

Then point the processor at that parameter name. While the clip plays, the curve is the weight.

### Parameters

#### Parameter

Name of the **float** Animator parameter. The field lists the float parameters found on the Animator.

#### Normalized By

Divides the parameter value. Use it when the curve was authored in a different range — a `0–100` curve with **Normalized By** `100` lands back in `0–1`.

{% hint style="warning" %}
If the Animator has no parameter with that name, the processor logs a warning and deactivates itself on enable. It will not silently hold your Set at zero.
{% endhint %}

***

## Animator Parameter Compare

A yes/no gate on any Animator parameter. Full weight when the comparison passes, zero when it fails.

### Parameters

#### Parameter

Name of the Animator parameter.

#### Parameter Type

`Float`, `Int` or `Bool`. It decides which comparison fields are shown.

#### Compare

The operator for `Float` and `Int`: equal, greater, less, and so on.

#### Value / Is True

The value to compare against.

***

## Look-At Range

Limits the weight by the angle between the character's forward direction and the **Aimer** direction. Inside the cone the IK works; outside it fades away.

This is what stops a head or spine look-at from twisting the character into impossible poses when the aim swings behind them.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FcGJcjXPk7eifKKGEXUDz%2Fimage.png?alt=media&#x26;token=75222034-beb0-4875-8ed3-6495493af156" alt="" width="518"><figcaption></figcaption></figure>

{% embed url="<https://streamable.com/kqgo51>" %}
When the direction leaves the Look-At cone the weight drops to zero
{% endembed %}

### Parameters

#### Look-At Limit

Min and Max angle in degrees. Below **Min** the weight is `1`; above **Max** it is `0`; in between it fades linearly. Both at `0` disables the check.

#### Angle Offset

Rotates the reference forward direction. Use it when the cone should not be centred on the character's forward — a shoulder-mounted camera, a sidestepping stance.

#### Normalize By

Divides the result.

#### Up Vector

The axis the angle is measured around: `Vector Up` (world), `Local` (a vector in character space) or `Global` (a `Vector3Var` asset).

#### Show Gizmos / Gizmo Radius / Gizmo Color

Draws the cone in the Scene View — a solid arc for the **Min** range and a darker one out to **Max**. Author the limits by looking at them, not by guessing numbers.

{% hint style="info" %}
The Set must have an **Aimer** assigned. Without one this processor returns `0`, which switches the whole Set off.
{% endhint %}

***

## Aimer has Target

Weight `1` while the **Aim** component has an active aim target, `0` otherwise. No settings.

Use it for IK that should only exist while the character is actually locked onto something — a head that follows an enemy, a hand that points at the current interactable. Invert it to do the opposite.

***

## Target Index Exist

Weight `1` when the given slot of the Set's `Targets` array holds a Transform, `0` when it is empty.

#### Target Index

The slot to check.

This is the safety net for Sets fed by an **IK Connector**: the ladder assigns its rungs, the Set turns on; the character lets go and the targets are cleared, the Set turns off on its own.

***

## Check Conditions2

Evaluates a **Conditions2** list against the character. Weight `1` when the conditions pass, `0` when they do not.

#### Check If

The condition list. Anything the Conditions system can test — stats, tags, distances, items, layers — becomes an IK gate.

This is the escape hatch: if none of the dedicated processors fit, this one almost certainly does.

***

## Weight State

Gates the IK on the Animal Controller's active **State**.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FhFggMFXEUoPiEjjVMKMS%2Fimage.png?alt=media&#x26;token=7cbf6c38-beab-4042-a37e-eb909723ec65" alt=""><figcaption></figcaption></figure>

#### States

The list of State IDs, with an **Include ✓ / Exclude ✕** switch.

* **Include** — weight `1` only while the character is in one of these States.
* **Exclude** — weight `1` everywhere **except** these States.

#### Profile

Also require the active State to be running this profile index. `-1` ignores the profile.

> *Example:* while the bow is being aimed and the character enters the water, the IK switches off until they are back on land.

***

## Weight Mode

Gates the IK on the **Modes** (and abilities) the character is playing.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FaJswLzbb0RnDNUs1CHCV%2Fimage.png?alt=media&#x26;token=b3ae6efd-12e9-49f2-8017-cb57bc81eaa4" alt=""><figcaption></figcaption></figure>

#### Modes

The list of Mode IDs with the **Include ✓ / Exclude ✕** switch. Leaving the list **empty** has two useful meanings:

| List        | Switch  | Result                                          |
| ----------- | ------- | ----------------------------------------------- |
| Has entries | Include | Weight `1` only while one of these Modes plays. |
| Has entries | Exclude | Weight `0` while one of these Modes plays.      |
| Empty       | Include | Weight `1` while **any** Mode plays.            |
| Empty       | Exclude | Weight `0` while **any** Mode plays.            |

The last row is the common one: *turn the IK off whenever the character does anything*.

#### Abilities

Indices to narrow the check down inside a Mode. Empty means every ability of the listed Modes counts.

#### Exclude Abilities

Flips the ability check, so the listed abilities are the ones that switch the IK off.

***

## Weight Stance

Gates the IK on the character's **Stance**.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FrhMYmseLmwkahoj8wA8z%2Fimage.png?alt=media&#x26;token=c39bd97d-74aa-49e3-9dba-1265d92c7074" alt=""><figcaption></figcaption></figure>

#### Stances

The list of Stance IDs with the **Include ✓ / Exclude ✕** switch, same rules as **Weight State**.

#### Stance Weight

The starting value, used before the first stance change is received. Set it to `1` if the Set should already be working at spawn.

{% hint style="warning" %}
**Weight State**, **Weight Mode** and **Weight Stance** need an Animal Controller (`MAnimal`) on the character. Without one they log a warning and deactivate themselves.
{% endhint %}

***

## Writing your own

A Weight Processor is a small serializable class with one required method.

```csharp
// Weight Processors/WeightMyGate.cs
using UnityEngine;

namespace MalbersAnimations.IK
{
    [System.Serializable, AddTypeMenu("My Gate")]
    public class WeightMyGate : WeightProcessor
    {
        // Shown as the row title in the list
        public override string DynamicName => $"My Gate [{Threshold}]";

        public float Threshold = 1f;

        // Return the multiplier. The IK Set applies Invert for you.
        public override float Process(IKSet set, Animator anim, float weight)
            => weight * (anim.velocity.magnitude > Threshold ? 1f : 0f);

        // Optional: subscribe/unsubscribe to events instead of polling
        public override void OnEnable(IKSet set, Animator anim) { }
        public override void OnDisable(IKSet set, Animator anim) { }

        // Optional: draw something in the Scene View
        public override void OnDrawGizmos(IKSet set, Animator anim) { }
    }
}
```

The class appears in the dropdown automatically, under the path given by `AddTypeMenu`.

{% hint style="info" %}
Prefer subscribing in `OnEnable` over testing in `Process`. `Process` runs every frame for every Set; the built-in State, Mode and Stance processors listen to the Animal Controller's events and just return a cached value.
{% endhint %}
