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

# Examples

> Use the supplied Sci-Fi controller, item, and weapon examples as references for your own gameplay implementation.

export const weaponExampleImageCaption_0 = "Weapon Example gameplay settings on a supplied firearm."

export const weaponExampleImage_0 = 
  <img
    src="/images/shooter-core/unity/weapon-example-component.png"
    alt="Weapon Example with fire rate, supported modes, burst rounds, and ammo capacity"
  />

export const productName_1 = "Sci-Fi FPS Pack"

export const productName_0 = "Sci-Fi FPS Pack"

<Frame caption="Gameplay Framework and Shooter Core components on the example player.">
  <img src="https://mintcdn.com/kinemation/107rkvEvtH7qBOZk/images/shooter-core/unity/shooter-core-components.png?fit=max&auto=format&n=107rkvEvtH7qBOZk&q=85&s=7c30fb3c0bc93c000a1212357fa25863" alt="Example player Inspector with Gameplay Framework and Shooter Core components" width="747" height="412" data-path="images/shooter-core/unity/shooter-core-components.png" />
</Frame>

## What the Example classes are for

The Example classes are executable reference implementations. They show how gameplay code can drive the animation and item presentation APIs, but they are not required base classes for your game.

Use them to answer three questions:

1. Which controller values must gameplay update?
2. Which ItemView lifecycle method corresponds to each gameplay action?
3. How should returned animation durations block incompatible actions?

Replace their movement, inventory, input, and game-state rules with your own architecture.

## GameplayControllerExample

<code>GameplayControllerExample</code> demonstrates a complete local character loop:

* Input System callbacks for movement, look, lean, jump, crouch, walk, sprint, free look, use, aim, inspect, and item switching.
* <code>CharacterController</code> movement with ground checks, coyote time, jumping, falling, air acceleration, crouch clearance, and stance transitions.
* Animator parameters for gait, movement direction, aiming, crouching, jumping, and in-air state.
* Per-frame updates to <code>GameplayAnimationController.moveInput</code>, <code>lookInput</code>, <code>deltaLookInput</code>, <code>leanInput</code>, and <code>isAiming</code>.
* Instantiation of configured item prefabs below the skeleton's mapped weapon bone.
* Action sequencing through returned durations, <code>StartAction</code>, <code>StopAction</code>, and <code>HasActiveAction</code>.

At startup, the controller ignores item prefabs without <code>GameplayItemExample</code>. It instantiates valid prefabs, hides their ItemViews, and equips the first item.

When the player changes items, it calls <code>UnEquipItem</code> on the active Example, waits for the returned holster duration, advances the item index, and calls <code>EquipItem</code> on the next Example.

## GameplayItemExample

<code>GameplayItemExample</code> is the gameplay-side adapter used by the reference controller. It caches <code>GameplayItemView</code> from the same GameObject and forwards:

| Example call                   | View call                        |
| ------------------------------ | -------------------------------- |
| <code>EquipItem(player)</code> | <code>OnEquipItem(player)</code> |
| <code>UnEquipItem()</code>     | <code>OnUnEquipItem()</code>     |
| <code>Aim(value)</code>        | <code>OnAim(value)</code>        |
| <code>UseItem()</code>         | <code>OnUseItem()</code>         |
| <code>StopUsingItem()</code>   | <code>OnStopUsingItem()</code>   |
| <code>InspectItem()</code>     | <code>OnInspect()</code>         |

The adapter has no inventory identity, cooldown, damage, ammo, or networking logic. Its purpose is to make every item look uniform to <code>GameplayControllerExample</code>.

## How to use the examples

Use the examples in layers:

* Compare your input and movement code with <code>GameplayControllerExample</code> to verify the values sent into <code>GameplayAnimationController</code>.
* Compare your inventory equip flow with its instantiate, hide, holster, delay, and equip sequence.
* Copy only the ItemView lifecycle calls required by your item.
* Keep your own authority and state decisions before those presentation calls.

A useful integration boundary is:

```text theme={null}
Input or network command
  -> gameplay validates the action
  -> gameplay changes authoritative state
  -> gameplay calls the ItemView presentation method
  -> returned duration controls local action overlap
```

The components in {productName_0} use this boundary. You can remove the Example classes after your controller reproduces the required animation-controller values and ItemView calls.

## ShooterControllerExample

<code>ShooterControllerExample</code> extends <code>GameplayControllerExample</code> with reload and fire-mode input. It treats the active item as <code>WeaponExample</code>, stops held fire before reload, and rejects reload or fire-mode changes while another controller action is active.

This class demonstrates input orchestration. It does not implement projectiles, hitscan, damage, weapon ownership, or networking.

## WeaponExample

<Frame caption={weaponExampleImageCaption_0}>
  {weaponExampleImage_0}
</Frame>

<code>WeaponExample</code> is the gameplay-side reference paired with <code>WeaponView</code>. Both components live on the same weapon prefab.

| Field                  | Demonstrated gameplay rule                                             |
| ---------------------- | ---------------------------------------------------------------------- |
| **Fire Rate**          | Converts rounds per minute into a delay of <code>60 / fireRate</code>. |
| **Supports Full Auto** | Adds Auto to the fire-mode cycle.                                      |
| **Burst Rounds**       | Enables Burst and limits the scheduled shots in that burst.            |
| **Ammo Capacity**      | Initializes and clamps the example's active ammo.                      |
| **Fire Mode**          | Selects Semi, Burst, or Auto behavior.                                 |

The class implements <code>IWeaponAmmo</code>. <code>WeaponView</code> finds that interface on its own GameObject and reads it to choose loaded or empty fire clips and tactical or empty reload clips.

The example owns demo cadence and ammo mutation:

1. <code>UseItem</code> validates active ammo and the fire-rate delay.
2. <code>Fire</code> subtracts one round, calls <code>WeaponView\.OnUseItem</code>, and schedules another shot when the selected mode requires it.
3. <code>StopUsingItem</code> cancels scheduled shots and stops recoil through the view.
4. <code>Reload</code> asks the view to select and play the correct reload presentation.
5. <code>ChangeFireMode</code> cycles only through modes enabled by the component fields.

It does not restore ammo when the reload animation finishes. A production weapon should change authoritative ammo through its own reload logic or animation-event policy.

## ChargeWeaponExample

<code>ChargeWeaponExample</code> specializes the demo's Burst mode into hold-to-charge behavior:

* Pressing use calls the view without immediately subtracting rounds.
* <code>ChargeWeaponView</code> plays charge-start and then repeats the charge loop.
* Releasing use subtracts <code>burstRounds</code>, calls <code>PlayFireEffects</code>, and stops the charge loop.

Semi and Auto still use the inherited <code>WeaponExample</code> cadence. Treat this as the reference for the {productName_1} energy charge rifle, then connect the release event to your own ammo and firing authority.

## Implement the same boundary

Your production gameplay component may replace <code>WeaponExample</code> entirely. Keep an <code>IWeaponAmmo</code> implementation on the same GameObject as <code>WeaponView</code> if the view should select loaded, empty, or partial presentation from current ammo.

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

public sealed class ProjectWeapon : MonoBehaviour, IWeaponAmmo
{
    [SerializeField] private WeaponView weaponView;
    [SerializeField] private int capacity = 30;
    [SerializeField] private float roundsPerMinute = 600f;

    private int activeAmmo;
    private FireMode fireMode = FireMode.Semi;

    private void Awake()
    {
        activeAmmo = capacity;
    }

    public float PresentEquip(GameObject player)
    {
        return weaponView.OnEquipItem(roundsPerMinute, fireMode, player);
    }

    public void FireAuthoritatively()
    {
        if (activeAmmo <= 0)
        {
            return;
        }

        activeAmmo--;
        weaponView.OnUseItem();
    }

    public int GetActiveAmmo() => activeAmmo;
    public int GetAmmoCapacity() => capacity;

    public void AddAmmo(int amount = 0)
    {
        activeAmmo = Mathf.Clamp(activeAmmo + amount, 0, capacity);
    }

    public void RestoreAmmo()
    {
        activeAmmo = capacity;
    }
}
```

The example leaves hit detection, projectiles, damage, replication, reload completion, and persistence to your gameplay code. The view remains responsible for paired animation, recoil, audio, VFX, FOV, and camera feedback.

## Supplied reference setup

The player reference is <code>Assets/KINEMATION/SciFiPack/Prefabs/Player/FPS\_SciFi\_Arms.prefab</code>. Its item list instantiates the six supplied <code>W\_\*</code> prefabs below the mapped weapon bone.

Each item prefab carries two distinct components:

* A concrete ItemView that owns presentation.
* An Example component that demonstrates gameplay state and calls the view.

See [Item views](/sci-fi-fps-pack/unity/general/item-views) for the exact pairing on the energy charge rifle, standard firearms, throwable, revolver, launcher, and shotgun.

## Adapt an example

<Steps>
  <Step title="Run the reference prefab">
    Test equip, holster, aim, use, stop-use, inspect, reload, and item switching before replacing code.
  </Step>

  <Step title="Trace the call boundary">
    Start at the Input System callback, follow the active Example component, and note the ItemView method it invokes.
  </Step>

  <Step title="Replace gameplay state">
    Move inventory, ammo, cooldown, projectile, damage, authority, and networking decisions into your own gameplay classes.
  </Step>

  <Step title="Preserve presentation calls">
    Invoke the matching ItemView lifecycle after your gameplay validates the action. Use returned durations to prevent incompatible local actions.
  </Step>

  <Step title="Remove the Example component">
    Remove it once your implementation supplies every required controller value and view call.
  </Step>
</Steps>

<Warning>
  Do not use <code>GameplayControllerExample</code>, <code>GameplayItemExample</code>, or <code>WeaponExample</code> as authoritative multiplayer gameplay. They are local examples designed to demonstrate the animation and presentation API.
</Warning>
