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

# Item views

> Understand the presentation views and matching example drivers on every supplied Sci-Fi FPS Pack item.

## What an ItemView represents

An ItemView is the presentation component on an equipped item prefab. It coordinates what the player sees and hears when gameplay equips, uses, aims, inspects, or holsters that item.

The view does not represent an inventory record or authoritative gameplay object. It does not decide ownership, damage, hit detection, ammunition persistence, networking, or whether an action is allowed.

| Layer              | Owns                                                                                                                       |
| ------------------ | -------------------------------------------------------------------------------------------------------------------------- |
| Your gameplay code | Inventory, input policy, authority, damage, cooldowns, ammo persistence, spawning, and networking.                         |
| Example component  | A small reference implementation of gameplay state that calls the view.                                                    |
| ItemView           | Paired character/item animation, procedural profile, item scale, visibility, audio, VFX, FOV, recoil, and camera feedback. |

## Base ItemView

<code>GameplayItemView</code> is the base presentation class. Keep it on the same GameObject as the item's <code>Animator</code>.

During <code>Awake</code>, the view:

1. Caches its original local scale and parent <code>GameplayAnimationController</code>.
2. Finds the item <code>Animator</code>.
3. Builds an animation slot mixer over the Animator's playable graph, or creates a graph when the Animator has none.
4. Caches child transforms for bone visibility.
5. Plays <code>itemIdleClip</code> as the base item pose.

<Warning>
  Without an Animator on the ItemView GameObject, the item animation graph is not initialized. Lifecycle calls still exist, but <code>PlayItemAnimation</code> returns false and paired item actions do not play.
</Warning>

## Paired character and item actions

<code>GameplayCharacterItemClip</code> groups a character-side <code>GameplayAnimationAsset</code>, an item-side asset, and an optional sound. <code>PlayCharacterItemAnimation</code> starts both animation assets together and plays the sound through the player's <code>AudioSource</code>.

Use paired assets for draw, holster, fire, reload, inspect, throw, and other actions where the hands and equipped object must remain synchronized.

## Equip context

<code>OnEquipItem(player)</code> resolves the active presentation context from the supplied player. When the argument is null, it uses the item's transform root.

The method then:

* Finds a child <code>GameplayAnimationController</code> and <code>GameplayCamera</code>.
* Applies the view's <code>proceduralAsset</code> to the character controller.
* Resolves any retargeted item scale from that procedural asset.
* Finds the context root's <code>AudioSource</code> for item sounds.

Call the base method from custom overrides before starting product-specific draw logic.

## Lifecycle contract

| Method                                           | When gameplay calls it                            | Base behavior                                                                               |
| ------------------------------------------------ | ------------------------------------------------- | ------------------------------------------------------------------------------------------- |
| <code>OnEquipItem(player)</code>                 | The item becomes active.                          | Resolves the player context and applies the procedural profile. Returns an action duration. |
| <code>OnUnEquipItem()</code>                     | The item is being holstered or replaced.          | Extension point that returns a duration.                                                    |
| <code>OnUseItem()</code>                         | Use begins or a one-shot action fires.            | Extension point.                                                                            |
| <code>OnStopUsingItem()</code>                   | A held use input ends.                            | Extension point.                                                                            |
| <code>OnAim(isAiming)</code>                     | Aim state changes.                                | Extension point.                                                                            |
| <code>OnInspect()</code>                         | Inspect begins.                                   | Extension point that returns a duration.                                                    |
| <code>SetItemVisibility(visible, delay)</code>   | Draw or holster controls when the object appears. | Activates or deactivates the item immediately or through a delayed call.                    |
| <code>PlayItemAnimation(asset, startTime)</code> | A custom view needs an item-only animation.       | Plays the asset through the view's animation slot mixer.                                    |
| <code>PlayCharacterItemAnimation(clip)</code>    | A custom view needs a synchronized action.        | Plays character animation, item animation, and sound together.                              |

Return the animation length for actions that should block other actions. Return zero for no blocking action. A specialized sequence may return a negative duration and stop the controller action itself when the sequence actually finishes.

## Bone visibility

<code>HideBoneByName</code> and <code>UnhideBoneByName</code> preserve the transform hierarchy and animation bindings. Hidden transforms are scaled to <code>0.001</code> during <code>LateUpdate</code>. Use this for magazines, cartridges, or throwable parts that animation events need to hide without deleting or disabling the animated transform.

<Note>
  In the current implementation, <code>UnhideBoneByName</code> stops forcing the small scale but does not restore the cached default scale itself. The animation or your event code must write the visible scale again.
</Note>

## GameplayItemExample

<code>GameplayItemExample</code> is a reference adapter, not the item presentation itself. It finds <code>GameplayItemView</code> on the same GameObject and forwards equip, unequip, aim, use, stop-use, and inspect calls.

The supplied <code>GameplayControllerExample</code> uses that adapter to demonstrate one complete loop:

1. It instantiates each configured item prefab below the mapped weapon bone.
2. It hides every item and equips the active one.
3. It forwards Input System callbacks to the active Example component.
4. It uses durations returned by equip, holster, and inspect to block overlapping actions.
5. On item change, it waits for the current view's holster duration before equipping the next item.

Use this as executable reference code. Your production controller can call an ItemView directly or provide its own adapter with the same lifecycle.

```csharp theme={null}
using UnityEngine;
using KINEMATION.Shared.GameplayFramework.Scripts.Runtime;

public sealed class InventoryItemPresentation : MonoBehaviour
{
    [SerializeField] private GameplayItemView itemView;

    public float Equip(GameObject player)
    {
        return itemView.OnEquipItem(player);
    }

    public float Holster()
    {
        return itemView.OnUnEquipItem();
    }

    public void SetAiming(bool isAiming)
    {
        itemView.OnAim(isAiming);
    }

    public void BeginUse()
    {
        itemView.OnUseItem();
    }

    public void EndUse()
    {
        itemView.OnStopUsingItem();
    }
}
```

The inventory system still decides when these methods are legal and how their returned durations affect its state.

## Included Sci-Fi item views

Every supplied item prefab combines a concrete ItemView with the Example component that drives it in the demo player.

| Prefab                   | ItemView                        | Example component                | What it demonstrates                                                                                         |
| ------------------------ | ------------------------------- | -------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| <code>W\_ARX\_Mk2</code> | <code>ChargeWeaponView</code>   | <code>ChargeWeaponExample</code> | Energy charge rifle. Burst mode becomes hold-to-charge; release fires and resets the charge presentation.    |
| <code>W\_Gepard</code>   | <code>WeaponView</code>         | <code>WeaponExample</code>       | Standard firearm lifecycle with recoil, muzzle flash, camera shake, fire audio, reload, inspect, and ADS.    |
| <code>W\_M97</code>      | <code>ThrowableItemView</code>  | <code>GameplayItemExample</code> | Held throwable sequence with throw-start, repeating hold loop, release delay, throw-end, and redraw.         |
| <code>W\_Onyx</code>     | <code>RevolverWeaponView</code> | <code>WeaponExample</code>       | Revolver presentation that selects a partial reload from the number of missing rounds.                       |
| <code>W\_RPG90</code>    | <code>WeaponView</code>         | <code>WeaponExample</code>       | Launcher presentation using the same standard firearm view contract with launcher-specific clips and data.   |
| <code>W\_TP12</code>     | <code>ShotgunWeaponView</code>  | <code>WeaponExample</code>       | Shell-by-shell reload, pump sequencing, multi-round fire length, and the product-specific cartridge display. |

## Choose a reference implementation

Start from the prefab whose presentation sequence matches your item:

* Use <code>W\_Gepard</code> or <code>W\_RPG90</code> for a conventional weapon using <code>WeaponView</code>.
* Use <code>W\_ARX\_Mk2</code> for an energy weapon that charges while use is held.
* Use <code>W\_Onyx</code> when reload selection depends on missing rounds.
* Use <code>W\_TP12</code> for an open-ended, shell-by-shell reload.
* Use <code>W\_M97</code> for a held throwable or another start-loop-release interaction.

Duplicate the prefab, preserve the ItemView and Example pairing while testing, and replace the Example component when your gameplay implementation is ready.

<Frame caption="ARX Mk2 energy charge rifle presentation fields.">
  <img src="https://mintcdn.com/kinemation/erlG3UUxfz5tRQKz/images/sci-fi-fps-pack/unity/charge-weapon-view.png?fit=max&auto=format&n=erlG3UUxfz5tRQKz&q=85&s=efe831c67dbd6a60c75fde47813b2ee9" alt="Charge Weapon View with charge-start, charge-loop, and charge audio settings" width="743" height="411" data-path="images/sci-fi-fps-pack/unity/charge-weapon-view.png" />
</Frame>

<Frame caption="Onyx partial reload entries on Revolver Weapon View.">
  <img src="https://mintcdn.com/kinemation/107rkvEvtH7qBOZk/images/shooter-core/unity/revolver-weapon-view.png?fit=max&auto=format&n=107rkvEvtH7qBOZk&q=85&s=b50dc97dbedc4dc2de7b53031167d74a" alt="Revolver Weapon View with partial reload animation entries" width="743" height="456" data-path="images/shooter-core/unity/revolver-weapon-view.png" />
</Frame>

<CardGroup cols={2}>
  <Card title="Weapon runtime" icon="crosshairs" href="/sci-fi-fps-pack/unity/general/weapon-runtime">
    Configure the Shooter Core view fields and specialized firearm behavior.
  </Card>

  <Card title="Example implementations" icon="code" href="/sci-fi-fps-pack/unity/general/examples">
    Adapt the supplied Example classes to your gameplay architecture.
  </Card>
</CardGroup>
