# How to create weapons and items

## First Steps

1- Place Item Model in Scene and Unpack Prefab

<div align="left"><figure><img src="https://2945806600-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCQMDx0LmgnRXXTklLhoh%2Fuploads%2Fowz24OYp4sAMnfNVVDTs%2Fimage.png?alt=media&#x26;token=8def347b-e01f-4bf5-a951-b146529fb222" alt=""><figcaption></figcaption></figure></div>

2- Set layer to "**Item**" layer

<div align="left"><figure><img src="https://2945806600-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCQMDx0LmgnRXXTklLhoh%2Fuploads%2FmcQ2vdg4DGiISdaf4cuk%2Fimage.png?alt=media&#x26;token=1c170489-1c74-4c5b-8f68-27ca9d2b6f75" alt=""><figcaption></figcaption></figure></div>

3- If you want use **Drop System** and **Pick Up System**, add a <mark style="color:green;">Collider</mark> and <mark style="color:green;">RigidBody</mark>

<div align="left"><figure><img src="https://2945806600-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCQMDx0LmgnRXXTklLhoh%2Fuploads%2FKphyVB16UDz6abEmUSRO%2Fimage.png?alt=media&#x26;token=fdf22868-3069-4321-95bf-4470236520e8" alt=""><figcaption></figcaption></figure></div>

4- Add any of the components below, configure it and create the prefab by dragging it to a folder in the Project window.

<div align="left"><figure><img src="https://2945806600-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCQMDx0LmgnRXXTklLhoh%2Fuploads%2FNwItGjZUvbKlYron1yKt%2Fimage.png?alt=media&#x26;token=4d830b98-81fb-46a7-985d-1e965160366b" alt=""><figcaption></figcaption></figure></div>



## Basic Holdable Item Setup

In JU TPS there are some types of ready-made holdable items, they are: <mark style="color:blue;">**General Holdable Item**</mark>, <mark style="color:orange;">**Weapon**</mark>, <mark style="color:red;">**Granade**</mark> and <mark style="color:yellow;">**Melee Weapon**</mark>

All holdable items will have the essential parameters below, this means you can repeat the first steps for all holdable items

<div align="left"><figure><img src="https://2945806600-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCQMDx0LmgnRXXTklLhoh%2Fuploads%2FiTQP6lef6EyBLnufrzTn%2Fimage.png?alt=media&#x26;token=0adb1507-42c8-4d96-86a1-dfc7be4b400a" alt=""><figcaption><p>Grenade component as an example of a holdable item</p></figcaption></figure></div>

| Parameters                | Description                                                                                                                                                                                                                                                                                    |
| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Unlocked                  | When checked, the item is ready to be equipped and used                                                                                                                                                                                                                                        |
| Item Name                 | Name of how the item will appear in the inventory, it is also required for other actions such as Pick Up                                                                                                                                                                                       |
| Item Switch ID            | Index for the Item Switch System, it is automatically set when the game starts, as the value must be according to the position in the hierarchy                                                                                                                                                |
| Item Filter Tag           | You should use this when you want to differentiate between types of items, to filter what can be equipped in an [Inventory Slot](../how-to-use-inventory-and-add-items/inventory-in-ui#inventory-slot-ui). <mark style="color:green;">⚠ Example: Primary Weapon, Secundary Weapon\[...]</mark> |
| Item Icon                 | Icon of the Item that will appear in the inventory and in the "Current Item Information" present in the default UI templates                                                                                                                                                                   |
| Item Quantity             | Quantity of items, if it is 0 the item will be blocked                                                                                                                                                                                                                                         |
| Item On Body              | Visual 3D model of the Item on the body, it is used to distribute the items on the body when not in use, not necessary if you don't want to                                                                                                                                                    |
| Single Use Item           | When used the item will be locked.                                                                                                                                                                                                                                                             |
| Continuous Use Item       | With this option, while the use button is being pressed, the item's use function will be called at each Frame                                                                                                                                                                                  |
| Block Fire Mode           | For items that don't need Fire Mode to work, like grenades and melee weapons, which can block Fire Mode to work properly                                                                                                                                                                       |
| Hold Pose                 | List of poses to hold item while not in Fire Mode                                                                                                                                                                                                                                              |
| Push Item From            | Basically the animation of equipping the item                                                                                                                                                                                                                                                  |
| Item Wielding Position ID | Wielding position index during FireMode (You can see IDs in [Item Aim Rotation Center](../how-to-use-inventory-and-add-items/how-to-align-weapon-rotation#item-aim-rotation-center-align))                                                                                                     |
| Is Left Hand Item         | This is to differentiate if the item is left hand item                                                                                                                                                                                                                                         |
| Force Dual Wielding       | The Item when equipped will activate the "_Dual Item to Wielding_" in the left hand and they will work together.                                                                                                                                                                               |
| Dual Item To Wielding     | Item in left hand to be activated when Item in right hand is equipped for Dual Wielding System to work.                                                                                                                                                                                        |
| Left Hand Position        | <p>A GameObject that stores the position and rotation of the left OR right hand wielding the item<br><mark style="color:green;">⚠ Example: the left hand supporting the right hand on the pistol</mark></p>                                                                                    |



## General Holdable Item Setup

It has no differences from the default holdable items settings other than events that you can use to call functions from code or simple actions like turning a light on and off:

<div align="left"><figure><img src="https://2945806600-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCQMDx0LmgnRXXTklLhoh%2Fuploads%2FfyHnPIfyvuLiOQgcRZZw%2Fimage.png?alt=media&#x26;token=fa7c3629-9f46-4b33-bfdf-afb0ff826be0" alt=""><figcaption></figcaption></figure></div>



## Weapon Item Setup

The Weapon Component has some unique parameters that you will need to configure:

<div align="left"><figure><img src="https://2945806600-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCQMDx0LmgnRXXTklLhoh%2Fuploads%2FUcO09YfQbc7ZK5cQVmPU%2Fimage.png?alt=media&#x26;token=dbf551f8-dfa5-48b9-8a4f-cf728d6e34b3" alt=""><figcaption></figcaption></figure></div>

| Precision System Parameters | Description                                                                                                                                   |
| --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| Accuracy                    | It's accuracy speed, the higher the faster the weapon will regain accuracy after a shot and the faster the crosshair on the screen will move. |
| Loss of Accuracy per Shot   | The higher it is, the less accurate the gun will be on each shot. It is recommended to leave it at a low value (like 0.1 - 1).                |

| Shooting System Parameters                           | Description                                                                                                                                                                                                                            |
| ---------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Shooting Position                                    | GameObject that keep the position where the bullet is instantiated, is also used to calculate the direction of the bullet.                                                                                                             |
| Bullet Prefab                                        | Prefab of Bullet                                                                                                                                                                                                                       |
| Muzzle Flash Prefab                                  | Prefab of Muzzle Flash Effect                                                                                                                                                                                                          |
| Fire Mode \[ Auto, Semi Auto, Bolt Action, Shotgun ] | <p><mark style="color:green;">Auto</mark>: Machinge Guns<br><mark style="color:yellow;">Semi Auto</mark>: Pistols<br><mark style="color:purple;">Bolt Action</mark>: Snipers<br><mark style="color:blue;">Shotgun</mark>: Shotguns</p> |
| Aim Mode \[ Camera Aproach, Scope Texture ]          | Weapon sight type                                                                                                                                                                                                                      |
| Camera Aiming Position                               | Camera position while aiming.                                                                                                                                                                                                          |
| Camera FOV                                           | Camera Aiming FOV                                                                                                                                                                                                                      |
| Fire Rate                                            | Shooting fire rate                                                                                                                                                                                                                     |
| Bullets in the Gun                                   | Bullets loaded in the magazine                                                                                                                                                                                                         |
| Total Amount of Bullets                              | Total bullets stored of the weapon                                                                                                                                                                                                     |
| Bullets for Reload                                   | Number of bullets per magazine                                                                                                                                                                                                         |
| Number of Shotgun Bullets per Shot                   | Number of bullet instances per shot in a shotgun                                                                                                                                                                                       |

| Procedural Animation Parameters | Description                                                                                                                       |
| ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| Enable                          | Enable procedural weapon animations.                                                                                              |
| Weapon Position Speed           | Speed at which the weapon returns to its original position after a shot.                                                          |
| Weapon Rotation Speed           | Speed at which the weapon returns to its original rotation after a shot.                                                          |
| Recoil Force                    | Force at which the gun pushes the hand back after a shot.                                                                         |
| Recoil Rotation Force           | Force at which the gun rotates the hand after a shot.                                                                             |
| Camera Recoil Multiplier        | Force that the recoil affects the direction of the camera.                                                                        |
| Slider Movement Axis            | Axis of movement of the weapon slider.                                                                                            |
| Gun Bolt/Slider                 | Weapon Slider GameObject                                                                                                          |
| Bolt/Slider Movement            | The distance the Slider will be pulled back after the shot.                                                                       |
| Bolt/Slider Speed               | Speed at which the Slider will return to its original position.                                                                   |
| Bullet Casing                   | Bullet casing, can be a GameObject to instantiate or a Particle System(you have to check the option below to use Particle System) |
| Is Particle System              | Bullet casing is a Particle System                                                                                                |

| Weapon Audio System Parameters | Description        |
| ------------------------------ | ------------------ |
| Shot Audio                     | Shot Audio Clip    |
| Reload Audio                   | Reload Audio Clip  |
| Weapon Equip Audio             | Equip Audio Clip   |
| Empty Magazine Audio           | No Ammo Audio Clip |



## Melee Weapon Setup

Melee weapons are simple:

<div align="left"><figure><img src="https://2945806600-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCQMDx0LmgnRXXTklLhoh%2Fuploads%2FONzFW6I7nmDktpmonpaL%2Fimage.png?alt=media&#x26;token=b5866ea4-63b8-434d-be5b-4d47f3fb6c95" alt=""><figcaption></figcaption></figure></div>

| Melee Weapon System Parameters | Description                                                                                                                                                                                                                                                                                                   |
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Attack Animator Parameter      | Parameter that triggers the sequence of attacks by the JU Character animator. So far by default there are three parameters in Animator: <mark style="color:yellow;">OneHandMeleeAttack</mark>, <mark style="color:blue;">TwoHandMeleeAttack</mark> and <mark style="color:orange;">DualHandMeleeAttack</mark> |
| [Damager](#damager) To Enable  | [Damager ](#damager)Gameobject to enable when using melee weapon.                                                                                                                                                                                                                                             |
| Enable Health Loss             | Enable health to item                                                                                                                                                                                                                                                                                         |
| Health                         | Health value                                                                                                                                                                                                                                                                                                  |
| Damage Per Use                 | When the [**Damager** ](#damager)collides, the weapon takes damage                                                                                                                                                                                                                                            |

### Damager

Damager is a script that basically works to damage any GameObject with JU Health Component.

<figure><img src="https://2945806600-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCQMDx0LmgnRXXTklLhoh%2Fuploads%2FzQuYVHNwEKvrz9veU7zn%2Fimage.png?alt=media&#x26;token=5297cf45-a9b7-4fb8-a9e5-a5e4ee9307a5" alt=""><figcaption></figcaption></figure>

Needs a <mark style="color:green;">collider</mark> and a <mark style="color:green;">rigidbody</mark> to detect collisions.

| Damager Parameters                      | Description                                                                                                                                                                                        |
| --------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Damage                                  | Damage                                                                                                                                                                                             |
| Disable On Start                        | Disable GameObject on game start                                                                                                                                                                   |
| Hit Min Time                            | Delay to hit again after a hit                                                                                                                                                                     |
| Raycasting Mode                         | This mode does not need a <mark style="color:green;">collider</mark> or a <mark style="color:green;">non-kinematic rigidbody</mark>.                                                               |
| Raycast Collide With                    | Raycast Layer Mask                                                                                                                                                                                 |
| Raycast Distance                        | Raycast Distance                                                                                                                                                                                   |
| Ignore All Colliders of Root GameObject | Ignores all colliders of the root GameObject (this is to ignore the player's body colliders for example and not damage itself)                                                                     |
| Lock Start Position                     | As the Damager needs a <mark style="color:green;">non-kinematic rigidbody</mark> to detect collisions, it is normal for it to physically move, this option locks the local position of the Damager |
| Tags To Damage                          | All tags listed here will receive damage on collision with the Damager (the object being collided needs a JU Health)                                                                               |
| Hit Particles List                      | Particle and audio effects for each tag                                                                                                                                                            |
| Hit Sounds Audio Source                 | Audio Source to play audio clips                                                                                                                                                                   |

## Throwable Item / Granade Setup

The Grenade Component is basically the Throwable Item Component with an explosion option:

<div align="left"><figure><img src="https://2945806600-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCQMDx0LmgnRXXTklLhoh%2Fuploads%2F5EV5CnESff4aif20OJ6M%2Fimage.png?alt=media&#x26;token=b0bf992e-bef2-4a8b-877a-eb539b3c9c72" alt=""><figcaption></figcaption></figure></div>

| Throw Parameters            | Description                                                                                                                                                                                                                              |
| --------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Animation Trigger Parameter | <p>Parameter that will be called in the JU Character animator to throw the object.<br><mark style="color:green;">⚠ Note that throw function is called by a</mark> <a href="broken-reference"><strong>JU Animation Event</strong></a></p> |
| Throw Force                 | Throw Force                                                                                                                                                                                                                              |
| Throw Up Force              | Throw Up Force                                                                                                                                                                                                                           |
| Rotation Force              | Throwed Object Rotation Force                                                                                                                                                                                                            |
| Seconds To Destroy          | <p>Seconds to destroy after being thrown. </p><p><mark style="color:blue;">⚠ Set the value to 0 if you don't want the object not to be destroyed</mark></p>                                                                              |
|  Position To Throw          | Throw Position (Pay attention to Gizmos)                                                                                                                                                                                                 |
| Direction To Throw          | Throw Direction (Pay attention to Gizmos)                                                                                                                                                                                                |

| Explosion Parameters      | Description                                       |
| ------------------------- | ------------------------------------------------- |
| Explosion Prefab          | Prefab with the explosion effect                  |
| Time To Explode           | Time for the grenade to explode                   |
| Time To Destroy Explosion | Time that the explosion effect will visually last |

### Explosion Effect

The explosion effect can be equipped with the Explosion Component which can physically simulate an explosion and deal damage to characters. It's also interesting to put the Shake One Time component in the explosion, it will do the [Camera Shake effect](../tools-utils-and-tutorials/camera-shake) (Make sure you have a [Shaker ](../tools-utils-and-tutorials/camera-shake)assigned to your Camera)

<div align="left"><figure><img src="https://2945806600-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCQMDx0LmgnRXXTklLhoh%2Fuploads%2FPSfNP21042TEVv4LlpPn%2Fimage.png?alt=media&#x26;token=8ab06d55-e29d-4549-9a58-b5d6e81ba971" alt=""><figcaption></figcaption></figure></div>
