> For the complete documentation index, see [llms.txt](https://finite-machine-studio.gitbook.io/vatmachine-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://finite-machine-studio.gitbook.io/vatmachine-documentation/api-reference.md).

# API Reference

The API lives in the `VATMachine.Runtime` namespace.

```csharp
using VATMachine.Runtime;
```

### VATAnimator

`VATAnimator` is the main runtime component used to control baked VAT animations from script.

```csharp
[DisallowMultipleComponent]
public sealed class VATAnimator : MonoBehaviour
```

#### Properties

```csharp
public VATAnimatorGraph Graph { get; }
public VATAnimatorState CurrentState { get; }
public IReadOnlyList<VATAnimatorLodTarget> LodTargets { get; }
public bool IsTransitioning { get; }
public bool HasActiveAnimationSample { get; }
```

`Graph`\
The VAT Animator Graph assigned to this animator.

`CurrentState`\
The current state being played by the animator.

`LodTargets`\
The renderer targets used by the animator for baked LODs and split mesh parts.

`IsTransitioning`\
Returns `true` while the animator is blending between two states.

`HasActiveAnimationSample`\
Returns `true` when the animator currently has valid animation data to sample.

#### Animation Event

```csharp
public event Action<VATAnimationEventContext> AnimationEventTriggered;
```

Called when a VAT animation event is reached during playback.

#### Play

```csharp
public void Play(string animationOrStateName)
```

Immediately plays a VAT animation or graph state by name.

The name can be either the state name in the VAT Animator Graph or the baked animation name.

#### Crossfade

```csharp
public void Crossfade(string animationOrStateName, float duration)
```

Blends directly into another animation or graph state.

#### Bool Parameters

```csharp
public void SetBool(string parameterName, bool value)
public bool GetBool(string parameterName)
```

Sets or reads a Bool parameter in the VAT Animator Graph.

#### Float Parameters

```csharp
public void SetFloat(string parameterName, float value)
public float GetFloat(string parameterName)
```

Sets or reads a Float parameter in the VAT Animator Graph.

#### Trigger Parameters

```csharp
public void SetTrigger(string parameterName)
public void ResetTrigger(string parameterName)
public bool GetTrigger(string parameterName)
```

Controls a Trigger parameter in the VAT Animator Graph.

```csharp
animator.SetTrigger("Attack");
```

Triggers stay active until they are consumed by a transition or reset manually.

```csharp
animator.ResetTrigger("Attack");
```

#### Local Socket Pose

```csharp
public bool TryGetSocketPose(string socketName, out VATSocketPose pose)
public bool TryGetSocketPose(int socketHash, out VATSocketPose pose)
```

Samples a baked socket pose in animator local space.

```csharp
if (animator.TryGetSocketPose("RightHand", out VATSocketPose pose))
{
    transform.localPosition = pose.LocalPosition;
    transform.localRotation = pose.LocalRotation;
}
```

#### World Socket Pose

```csharp
public bool TryGetSocketWorldPose(string socketName, out Vector3 position, out Quaternion rotation)
public bool TryGetSocketWorldPose(int socketHash, out Vector3 position, out Quaternion rotation)
```

Samples a baked socket pose and converts it to world position and rotation.

```csharp
if (animator.TryGetSocketWorldPose("RightHand", out Vector3 position, out Quaternion rotation))
{
    weapon.transform.SetPositionAndRotation(position, rotation);
}
```

### VATSocketLink

`VATSocketLink` makes a GameObject follow a baked VAT socket automatically.

```csharp
[ExecuteAlways]
[DisallowMultipleComponent]
public sealed class VATSocketLink : MonoBehaviour
```

#### Properties

```csharp
public VATAnimator Animator { get; set; }
public string SocketName { get; set; }
public int SocketHash { get; }
```

`Animator`\
The `VATAnimator` that owns the socket data. You can assign or change this from script.

`SocketName`\
The socket currently being followed. You can change this at runtime to switch the linked object to another socket.

`SocketHash`\
The hashed socket name. Most users do not need this unless they are doing lower-level socket logic.

#### Notes

`VATSocketLink` updates automatically in `LateUpdate`.

If you only need a prop or VFX object to follow a socket, use `VATSocketLink`.

If you need custom movement logic, use `VATAnimator.TryGetSocketPose()` or `VATAnimator.TryGetSocketWorldPose()` instead.

### VATAnimationEventContext

`VATAnimationEventContext` is passed when a VAT animation event is triggered.

```csharp
public readonly struct VATAnimationEventContext
{
    public readonly VATAnimator Animator;
    public readonly VATAnimatorState State;
    public readonly VATAnimationEventMarker Event;
    public readonly float StateTime;
    public readonly float StateElapsed;
    public readonly VATBlendTreeChildMotion BlendTreeMotion;
    public readonly VATAnimatorClipInfo animatorClipInfo;
    public bool IsBlendTreeMotionEvent { get; }
}
```

#### Properties

`Animator`\
The `VATAnimator` that fired the event.

`State`\
The graph state that fired the event.

`Event`\
The event marker data, including event name, frame, string parameter, and object reference.

`StateTime`\
The normalized time of the state when the event fired.

`StateElapsed`\
The elapsed time in seconds inside the state.

`BlendTreeMotion`\
The blend tree child motion that fired the event, if the event came from a blend tree child.

`animatorClipInfo`\
Contains the event blend weight.

`IsBlendTreeMotionEvent`\
Returns `true` if the event came from a blend tree child motion.

#### Example

```csharp
private void HandleAnimationEvent(VATAnimationEventContext context)
{
    switch (context.Event.eventName)
    {
        case "Footstep":
            Debug.Log("Surface: " + context.Event.stringParameter);
            break;

        case "PlaySound":
            AudioClip clip = context.Event.objectReference as AudioClip;
            break;
    }
}
```

### VATAnimationEventMarker

`VATAnimationEventMarker` stores the data for one animation event.

```csharp
[Serializable]
public sealed class VATAnimationEventMarker
{
    public string eventName;
    public int frame;
    public string stringParameter;
    public UnityEngine.Object objectReference;

    public int ResolveFrame(VATAnimationData animation);
    public float ResolveTime(VATAnimationData animation);
    public void SetFrame(int newFrame, VATAnimationData animation)
    public void Sanitize(VATAnimationData animation);
}
```

Most users will read event marker values from `VATAnimationEventContext.Event` instead of creating event markers from code.

#### Fields

`eventName`\
The event name used by scripts to decide what should happen.

`frame`\
The frame where the event fires.

`stringParameter`\
Optional text data passed with the event.

`objectReference`\
Optional Unity object reference passed with the event.

#### Useful Methods

```csharp
public int ResolveFrame(VATAnimationData animation)
public float ResolveTime(VATAnimationData animation)
```

Use these if you need to convert an event marker into a valid frame or time for a specific `VATAnimationData` asset.

### VATAnimatorClipInfo

`VATAnimatorClipInfo` contains blend weight information for animation events.

```csharp
public readonly struct VATAnimatorClipInfo
{
    public float weight { get; }
}
```

#### weight

`weight` tells how much influence the animation had when the event fired.

This can be useful during crossfades or blend trees if you want to ignore events from animations that have very low influence.

```csharp
private void HandleAnimationEvent(VATAnimationEventContext context)
{
    if (context.animatorClipInfo.weight < 0.5f)
        return;

    Debug.Log(context.Event.eventName);
}
```

### VATSocketPose

`VATSocketPose` represents a sampled socket pose in animator local space.

```csharp
public readonly struct VATSocketPose
{
    public readonly Vector3 LocalPosition;
    public readonly Quaternion LocalRotation;

    public VATSocketPose(Vector3 localPosition, Quaternion localRotation);
    public static VATSocketPose Lerp(VATSocketPose from, VATSocketPose to, float t);
}
```

#### Fields

`LocalPosition`\
The socket position relative to the `VATAnimator` transform.

`LocalRotation`\
The socket rotation relative to the `VATAnimator` transform.

### VATAnimationData

`VATAnimationData` is the baked animation asset created by VATMachine.

```csharp
public sealed class VATAnimationData : ScriptableObject
```

Most users assign this asset through the editor, but some scripts may read basic information from it.

#### Useful Properties

`AnimationName`\
Name of the baked animation.

`FrameCount`\
Number of baked animation frames.

`Duration`\
Animation duration in seconds.

`FrameRate`\
Playback frame rate derived from the baked data.

`Loop`\
Whether the animation is intended to loop.

`Bounds`\
Bounds of the baked animation.

`LodCount`\
Number of baked LODs.

`SocketData`\
Read-only list of baked socket data.

`IsValid`\
Returns `true` if the data contains the required playback information.

#### Socket Sampling

```csharp
public bool TrySampleSocket(string socketName, float time, out VATSocketPose pose)
public bool TrySampleSocket(int socketHash, float time, out VATSocketPose pose)
```

Samples a baked socket directly from the animation data.

Most users should use `VATAnimator.TryGetSocketPose()` instead, because the animator already knows the current animation time, transition, and blend state.

### What Is Not Included Here

This page intentionally does not list every public enum, graph-editing method, bake configuration method, texture property, or internal data layout property.

Those APIs are mainly useful for custom editor tools, advanced debugging, or extending VATMachine itself. For normal gameplay scripting, the APIs above are the ones users are expected to use.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://finite-machine-studio.gitbook.io/vatmachine-documentation/api-reference.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
