> For the complete documentation index, see [llms.txt](https://cowsinss-organization.gitbook.io/fps-engine-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cowsinss-organization.gitbook.io/fps-engine-documentation/how-to-use/adding-new-weapons.md).

# Adding New Weapons

Refer to this tutorial for instructions on adding new weapons. This section of the documentation will cover the same steps in detail.

{% embed url="<https://www.cowsins.com/videos/1085953150>" %}

***

### Requirements

In order to add a new Weapon, you will need:

* Custom arm Rig and Weapon models if desired.
* Custom VFX if desired.
* Custom SFX if desired.&#x20;

Note that you can use the assets provided by FPS Engine if you want!

### Procedure

First, we must create a new [Weapon\_SO](/fps-engine-documentation/content/03.-content/03.4-weapons/weapon_so.md). You can store them anywhere , but it´s good practice to keep them all in the same folder.&#x20;

You can create a unique Weapon\_SO for each weapon by right-clicking in your Project folder, going to Create → COWSINS → New Weapon.

<figure><img src="https://2716441118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkdlNMXOYYmupb4VpBGHT%2Fuploads%2FnCd3AdFImXUA2nMPpZEh%2Fimage.png?alt=media&amp;token=3e238469-f773-4813-b9cd-255b8c8e1125" alt="" width="352"><figcaption></figcaption></figure>

<figure><img src="https://2716441118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkdlNMXOYYmupb4VpBGHT%2Fuploads%2FAM5eKx74MVGowXIdxZ4J%2Fimage.png?alt=media&amp;token=ca44570a-6c7b-4b49-9570-ebf8f0f582ca" alt=""><figcaption></figcaption></figure>

When you create a New Weapon\_SO, all the variables will be resetted, you can apply a Preset or duplicate an existing Weapon\_SO instead.

To apply a preset simply select it on "currentPreset" and apply.

<figure><img src="https://2716441118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkdlNMXOYYmupb4VpBGHT%2Fuploads%2FaPlwQXlQSQrD8P6Pt9JK%2Fimage.png?alt=media&amp;token=8b4bcd66-11bc-4191-b592-02455ba6fb2c" alt="" width="357"><figcaption></figcaption></figure>

Now, you can modify all the parameters as you need to create your desired Weapon! If you need further explanation on what each parameter does, please refer to [Weapon\_SO](/fps-engine-documentation/content/03.-content/03.4-weapons/weapon_so.md).&#x20;

Once we have the **Weapon\_SO** created, we need a **Weapon Prefab**. We will search the CowsinsBlankWeaponTemplate which is located under the following path.

<figure><img src="https://2716441118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkdlNMXOYYmupb4VpBGHT%2Fuploads%2FFMNdnijYav9ogQoC38cE%2Fimage.png?alt=media&amp;token=f49786a5-6f5c-4e36-bab6-eb259211a317" alt=""><figcaption></figcaption></figure>

We want to duplicate this object ( Ctrl+D ) and give it a name, then open it.

<figure><img src="https://2716441118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkdlNMXOYYmupb4VpBGHT%2Fuploads%2F0HDCm8AK8nmbRtojrvWY%2Fimage.png?alt=media&amp;token=a3c9a40a-8740-41e8-9ec5-b34ad38f8ee9" alt=""><figcaption></figcaption></figure>

Here, we will import our model under “Meshes”. Note that the cube is approximately the size and location of the weapon we want to add. When you are happy with the location of the model, delete the cube.&#x20;

{% hint style="info" %}
In FPS Engine, the Weapon Prefab should contain both the Arms and Weapon
{% endhint %}

<figure><img src="https://2716441118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkdlNMXOYYmupb4VpBGHT%2Fuploads%2FiH6qFGgpeToiScQuLuq8%2Fimage.png?alt=media&amp;token=84b586b9-83fa-40ac-999a-bf6b87af0652" alt=""><figcaption></figcaption></figure>

Now create a new empty object as a child of the imported model and call it FirePoint. Note that you can create as many fire points as you want, so you can make two handed weapons etc. You want to locate the fire point at the tip of the barrel.

<figure><img src="https://2716441118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkdlNMXOYYmupb4VpBGHT%2Fuploads%2FJUqdT5EeLd3vBJIbwSfj%2Fimage.png?alt=media&amp;token=1071cda9-99a1-46d6-a7a0-474c5bafaad3" alt=""><figcaption></figcaption></figure>

We will need to locate the AimPoint at the Iron Sights / Scope

<figure><img src="https://2716441118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkdlNMXOYYmupb4VpBGHT%2Fuploads%2FvyguRoZHk8FQKF7R0Wwo%2Fimage.png?alt=media&amp;token=37ac35ac-4657-4bdb-b3e0-91d4a9c609f3" alt=""><figcaption></figcaption></figure>

Now go to the root of the prefab and attach your fire points, the Aim Point and the Weapon\_SO we created before.

<figure><img src="https://2716441118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkdlNMXOYYmupb4VpBGHT%2Fuploads%2Fp4iZoI8eEt9MauTd9EeS%2Fimage.png?alt=media&amp;token=f542cdbb-4f13-4955-84dc-3a0338b15182" alt=""><figcaption></figcaption></figure>

Now, go to your scriptable object and attach this prefab into weaponObject, under the Basic tab.

<figure><img src="https://2716441118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkdlNMXOYYmupb4VpBGHT%2Fuploads%2FgcdiuXm7iVHqissRvZkI%2Fimage.png?alt=media&amp;token=55ba60b8-8d4e-462b-89d1-5afe513d3dac" alt=""><figcaption></figcaption></figure>

Just like this, our Weapon is ready. If you want to add Animations to the Weapon, refer to the next section

### Adding Animations

There is an animator attached to the root of the Weapon Prefab. You should ensure you move this Animator component to exactly the root of your Animations. If you imported an animated Rig from Blender, the imported object is likely to be the root.

{% hint style="danger" %}
Animator Component Miss Placement will result in the Animations not working.&#x20;

Please, ensure you locate the Animator Component Properly.
{% endhint %}

{% hint style="info" %}
If you want to animate inside Unity, you can leave the component at the root of the Prefab, or re-locate it if you wish.
{% endhint %}

As you can see there is no Animation Controller Attached to this Animator component, so we need to create it. There is an Animation Controller template stored in the following path: Assets/Cowsins/Animations/AnimationControllerTemplate.

<figure><img src="https://2716441118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkdlNMXOYYmupb4VpBGHT%2Fuploads%2FtFKU3Hmb4jV1PzVu8Ive%2Fimage.png?alt=media&amp;token=04935ce4-545e-4d15-8408-2aa60c755669" alt=""><figcaption></figcaption></figure>

You can duplicate this and attach it to your “Controller” on the Animator component.

<figure><img src="https://2716441118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkdlNMXOYYmupb4VpBGHT%2Fuploads%2FBB8xa7NygxVvOKz4O92e%2Fimage.png?alt=media&amp;token=402034b4-1389-466f-ae35-97dc63fe2932" alt=""><figcaption></figcaption></figure>

You can open this animation controller and take a look. This will pop up:

<figure><img src="https://2716441118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkdlNMXOYYmupb4VpBGHT%2Fuploads%2FiEHNdccnB5MSUG2aGaHn%2Fimage.png?alt=media&amp;token=e3024874-a9e0-4e14-af78-c0b57f893425" alt=""><figcaption></figcaption></figure>

As you may notice, all these parameters and structure are already set-up.

All you have to do is to create an animation for each state (Idle, Unholster, Shoot, Reload) and then attach them to each animation State( If you already have the animations, directly attach them to the corresponding states ).

For example: Let´s say we have just made an idle animation. Click on the Idle Animation State.

<figure><img src="https://2716441118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkdlNMXOYYmupb4VpBGHT%2Fuploads%2FBylUp29yX4MxU2PFu33H%2Fimage.png?alt=media&amp;token=c7761054-4972-430d-a469-0a837824da53" alt=""><figcaption></figcaption></figure>

Attach your animation in Motion. Repeat the process with the remaining animation States.

<figure><img src="https://2716441118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkdlNMXOYYmupb4VpBGHT%2Fuploads%2FbdSOrgxvJoarHAfp7YFl%2Fimage.png?alt=media&amp;token=25e4f221-bb6f-407e-9a26-81fad2435eb6" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
he length of animations like Reload depends on the statistics you set for your weapon (such as Reload time). For shooting, the length doesn't matter if you use the blank template, as the animation will restart after each shot. For idle, walk, run, and inspect animations, these should be the only ones marked as "loop."
{% endhint %}

### Custom Animation States

You can create custom animation states if needed, but note that these are not provided by the asset, so you will have to set them up yourself. Below, you will find a guide on how to do this effectively using FPS Engine.

1. Open the animation controller for the weapon you desire to add a new Animation State.
2. Go to the Parameters tab for this Animation Controller and click on the "+" button. Add a Trigger, name the new parameter, and remember its name. For example, you can name it "myCoolNewBoolean."
3. Make a new state and add a motion ( Animation Clip )
4. Add the required animation transitions.
5. Look for the suitable method where you want to introduce the state by code. Then write this:

```csharp
CowsinsUtilities.PlayAnim("myCoolNewBoolean", 
    inventory[currentWeapon].GetComponentInChildren<Animator>());
```

If you can't find the appropriate function, feel free to ask for [support](/fps-engine-documentation/support/support.md).

### Best Practices

It is highly recommended to use the provided template for creating weapons. Following the same structure as the example weapons included with the asset is advisable as well.
