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

# ⚙️Weapon System

> In this page we will cover how the weapons works in the project.

## Weapon Components

From the previos chapter we know that **Weapon Manager** and **Viewmodel Controller** are used to manage weapons. First, let's clarify the differences between these components:

* **Weapon Manager**: spawns and swaps weapons; works like a simple inventory system.

* **Viewmodel Controller**: tells what weapons and character mesh to use; controls the first-person view.

Each component does not work out of the box. Instead, they provide basic functions that are supposed to be called in a player blueprint (**BP\_Viewmodel** example).

## Weapon Manager

This component has to be initialized when the game starts:

<Frame caption={"Call Initialize Weapon first."}>
  <img src="https://mintcdn.com/kinemation/6K2VhvCCGB3AmUKf/images/fps-animation-pack/unreal/7589e53755a612add7ad.png?fit=max&auto=format&n=6K2VhvCCGB3AmUKf&q=85&s=dd7e1ab8030acf8bd109aa1f39386c91" alt="" width={476} data-path="images/fps-animation-pack/unreal/7589e53755a612add7ad.png" />
</Frame>

Next, it is used to change weapons:

<Frame caption={"Changing Weapons."}>
  <img src="https://mintcdn.com/kinemation/6K2VhvCCGB3AmUKf/images/fps-animation-pack/unreal/c6281a009d959b6eb4cd.png?fit=max&auto=format&n=6K2VhvCCGB3AmUKf&q=85&s=c6da94a086afd1ffba20f48eabeee594" alt="" width={455} data-path="images/fps-animation-pack/unreal/c6281a009d959b6eb4cd.png" />
</Frame>

This method will invoke a weapon change with animation. However, there is a function that allows instant weapon change:

<Frame caption={"Immediately equips next or previous weapon."}>
  <img src="https://mintcdn.com/kinemation/6K2VhvCCGB3AmUKf/images/fps-animation-pack/unreal/ef2fe93b4f291699efc7.png?fit=max&auto=format&n=6K2VhvCCGB3AmUKf&q=85&s=273e374c5da6ce1be7abfe28bf153858" alt="" width={563} data-path="images/fps-animation-pack/unreal/ef2fe93b4f291699efc7.png" />
</Frame>

If **Forward** it true, the next weapon will be equipped, if false - the previous one.

Finally, **Weapon Manager** is used to manually update **Weapon Settings** when switching between UE4/UE5 meshes:

<Frame caption={"Swapping meshes."}>
  <img src="https://mintcdn.com/kinemation/PlmzVQHJ3J_C1x92/images/fps-animation-pack/unreal/20c149ddad2cff522436.png?fit=max&auto=format&n=PlmzVQHJ3J_C1x92&q=85&s=ac645383716250ea8456d6739d02337a" alt="" width={563} data-path="images/fps-animation-pack/unreal/20c149ddad2cff522436.png" />
</Frame>

You can find out more about the internal logic of the **Weapon Manager** component by opening its Blueprint (**Blueprints** → **Character** → **WeaponManager**).

## Viewmodel Controller

Before working with the component, it is vital to assign the **Character Settings** asset:

<Frame caption={"Assign Character Settings."}>
  <img src="https://mintcdn.com/kinemation/6K2VhvCCGB3AmUKf/images/fps-animation-pack/unreal/eea026441df8ba910229.png?fit=max&auto=format&n=6K2VhvCCGB3AmUKf&q=85&s=288f493e911161a22d3d4b09d1416a70" alt="" width={373} data-path="images/fps-animation-pack/unreal/eea026441df8ba910229.png" />
</Frame>

**Viewmodel Controller** serves as an interface between the gameplay lofic and animation blueprints. That is why it is essential to update its public properties manually:

<Frame caption={"Update Gait."}>
  <img src="https://mintcdn.com/kinemation/6K2VhvCCGB3AmUKf/images/fps-animation-pack/unreal/e05457c9aac01021f548.png?fit=max&auto=format&n=6K2VhvCCGB3AmUKf&q=85&s=838372de15b24776f927493416b41637" alt="" width={269} data-path="images/fps-animation-pack/unreal/e05457c9aac01021f548.png" />
</Frame>

The **Gait** parameter represents the normalized character movement state:

* **\[0;1]** range defines a transition between idle and walking.

* **\[1;2]** range defines a transition between walking and sprinting.

* **\[2;3]** range defines a transition between sprinting and tactical sprinting.

Next, we need to update the firing trigger state - it will control the index finger rotation:

<Frame caption={"Animates the right index finger when firing."}>
  <img src="https://mintcdn.com/kinemation/6K2VhvCCGB3AmUKf/images/fps-animation-pack/unreal/85a8ec3b4ad60309cf93.png?fit=max&auto=format&n=6K2VhvCCGB3AmUKf&q=85&s=ab2ba2ba0c175372af56cdb2fdda2d29" alt="" width={411} data-path="images/fps-animation-pack/unreal/85a8ec3b4ad60309cf93.png" />
</Frame>

To active procedural aiming, make sure to update the aiming flag:

<Frame caption={"Update aiming."}>
  <img src="https://mintcdn.com/kinemation/6K2VhvCCGB3AmUKf/images/fps-animation-pack/unreal/a4a64f4e9efdc98605c0.png?fit=max&auto=format&n=6K2VhvCCGB3AmUKf&q=85&s=37545b4a87f87303da50e1f19fdc65d1" alt="" width={390} data-path="images/fps-animation-pack/unreal/a4a64f4e9efdc98605c0.png" />
</Frame>

Finally, we can use **Viewmodel Controller** to play custom *IK Motions* - simple transition animations which can make flat transitions feel more dynamic.

<Tip>
  **Tip**: *IK Motion* is used when aiming down sights.
</Tip>

<Frame caption={"Select an IK Motion."}>
  <img src="https://mintcdn.com/kinemation/PlmzVQHJ3J_C1x92/images/fps-animation-pack/unreal/509966c4ce8cf503d7a0.png?fit=max&auto=format&n=PlmzVQHJ3J_C1x92&q=85&s=02e0ab785a62c2b35fcedf09414fd315" alt="" width={359} data-path="images/fps-animation-pack/unreal/509966c4ce8cf503d7a0.png" />
</Frame>

We will cover the IK Motion asset later in the documentation. Now let's figure out how weapons work.
