# How to create weapons and items

## First Steps

1- Place Item Model in Scene and Unpack Prefab

<div align="left"><figure><img src="/files/ZFv7Ci9ZCR2CmAQTdwac" alt=""><figcaption></figcaption></figure></div>

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

<div align="left"><figure><img src="/files/XUJE6Aeys86gVbLRkBLN" 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="/files/la8s6DYHjzsKRJ4uYYnz" 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="/files/Z9XBmIG8FLo87osJjqID" 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="/files/rjSnpSYjTFMQPB3eZqwe" 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](/ju-tps-documentation/game-development/how-to-use-inventory-and-add-items/inventory-in-ui.md#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](/ju-tps-documentation/game-development/how-to-use-inventory-and-add-items/how-to-align-weapon-rotation.md#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="/files/tBNLad36wOOdQ5JKpi78" 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="/files/WtL8S9uhWPYAB3Us6dLk" 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="/files/9mNHoKTaG3V4CrohvCej" 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="/files/POFNwkv4RqGsdS2a7jYM" 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="/files/I0Gpn2n3CYb6NCeEiRy3" 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="/pages/DKyl2oIU5IYYm9BZXk5Z"><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](/ju-tps-documentation/tools-utils-and-tutorials/camera-shake.md) (Make sure you have a [Shaker ](/ju-tps-documentation/tools-utils-and-tutorials/camera-shake.md)assigned to your Camera)

<div align="left"><figure><img src="/files/tCkiWsyDYTAzTKeQW6nA" alt=""><figcaption></figcaption></figure></div>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://julhiecio.gitbook.io/ju-tps-documentation/game-development/how-to-create-weapons-and-items.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
