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

# SimpleAnimationPlayer Component Reference and API Guide

> Play weapon and prop animations from code with SimpleAnimationPlayer — no Animator Controllers needed. Set a base pose and trigger clips via PlayAnimation.

The **SimpleAnimationPlayer** component lets you drive animations on a GameObject entirely from code, without needing to author an Animator Controller. It is designed primarily for animated props such as weapons, tools, and items — objects that need a small set of clips triggered on demand rather than a full state machine. Add it to the same GameObject as the `Animator` component, configure a default pose, and call its API methods whenever you want to play a clip.

## Component Properties

The following two properties appear in the Inspector when `SimpleAnimationPlayer` is added to a GameObject.

<ParamField path="Use Animator" type="bool">
  When enabled, animations played by `SimpleAnimationPlayer` are layered on top of an existing Animator Controller. The Animator continues to run its state machine, and the clip played by `SimpleAnimationPlayer` blends over it. When disabled, no Animator Controller is needed — the **Default Clip Pose** is used as the base pose instead.
</ParamField>

<ParamField path="Default Clip Pose" type="AnimationClip">
  The animation clip that plays as the resting pose when **Use Animator** is `false`. Assign your weapon's idle or held pose here. This clip loops continuously as the base layer until another clip is triggered via `PlayAnimation`.
</ParamField>

<Note>
  `SimpleAnimationPlayer` must be placed on the same GameObject as the `Animator` component. It hooks into the Playables API underneath and requires the Animator to be present to function.
</Note>

## Use Cases

`SimpleAnimationPlayer` is the recommended approach for animated props and weapons. Rather than creating and maintaining a separate Animator Controller for every item in your game, you keep animation logic in code and simply call `PlayAnimation` or `PlayBasePlayable` when an action occurs. This keeps your asset database clean and makes it easy to add new items without any additional Animator Controller authoring.

Typical scenarios include:

* Playing a weapon idle pose on equip.
* Triggering a reload animation when the player reloads.
* Playing an inspect or interact animation on demand.
* Driving secondary prop animations (torch flicker, barrel sway) from gameplay events.

## API Reference

### PlayAnimation

```csharp theme={null}
public bool PlayAnimation(AnimationAsset newAnimation, float startTime = 0f)
```

Plays an **AnimationAsset** on the component. `AnimationAsset` is a CAS ScriptableObject that wraps an `AnimationClip` and adds per-asset control over playback speed and blend settings.

Returns `true` if the animation started successfully, or `false` if the asset was null or playback failed.

| Parameter      | Type             | Description                                                                                    |
| -------------- | ---------------- | ---------------------------------------------------------------------------------------------- |
| `newAnimation` | `AnimationAsset` | The Animation Asset to play.                                                                   |
| `startTime`    | `float`          | Optional normalized start time in the `[0, 1]` range. Defaults to `0` (beginning of the clip). |

<Tip>
  Use `AnimationAsset` (rather than a raw `AnimationClip`) when you need per-instance control over playback speed, blend-in duration, or blend-out duration. You can create Animation Assets via right-click **▸ Create ▸ KINEMATION ▸ Animation Asset** in the Project window.
</Tip>

### PlayBasePlayable

```csharp theme={null}
public void PlayBasePlayable(AnimationClip clip)
```

Sets a raw `AnimationClip` as the base pose and starts playing it immediately. Use this to establish the looping idle pose for a prop or weapon on equip, before any action animations are triggered.

| Parameter | Type            | Description                                 |
| --------- | --------------- | ------------------------------------------- |
| `clip`    | `AnimationClip` | The clip to use as the base (looping) pose. |

## Code Example

The following script demonstrates a complete weapon animation setup using `SimpleAnimationPlayer`. On `Start`, it establishes the weapon's idle pose; a separate method triggers the reload animation when called by gameplay logic.

```csharp theme={null}
using UnityEngine;
using Kinemation.CAS.Runtime; // adjust namespace to match your CAS version

public class WeaponExample : MonoBehaviour
{
    [SerializeField] private AnimationClip weaponIdlePose;
    [SerializeField] private AnimationAsset reloadAnimation;

    private SimpleAnimationPlayer _animationPlayer;

    private void Start()
    {
        // 1. Get the SimpleAnimationPlayer on this GameObject.
        _animationPlayer = GetComponent<SimpleAnimationPlayer>();

        // 2. Set and play the weapon's base (idle) pose.
        if (_animationPlayer != null)
        {
            _animationPlayer.PlayBasePlayable(weaponIdlePose);
        }
    }

    // Call this from your weapon's reload logic.
    public void PlayReloadAnimation()
    {
        // 3. Play the reload AnimationAsset on demand.
        if (_animationPlayer != null)
        {
            _animationPlayer.PlayAnimation(reloadAnimation);
        }
    }
}
```

After the reload animation finishes, `SimpleAnimationPlayer` automatically blends back to the base pose clip you set with `PlayBasePlayable`. You do not need to manually restore the idle state.
