# Explosive

## Creating an Explosive

Explosives rely on the `Explosive` component to handle all explosion-related functionality, including force, damage, visual effects, and more. To create a new explosive, either drag and drop your explosive model into the scene or create an empty GameObject to serve as its base.

{% hint style="info" %}
You can find all default explsive barrels at `FPS Framework > Art > Models > Props`
{% endhint %}

<figure><img src="/files/qzzN5uopl4Pgcwpzmx1o" alt=""><figcaption><p>Default expslove black barrel</p></figcaption></figure>

Since this is a new GameObject, it won't have any components by default unless it's a model, which may come with some. To make the explosive functional, begin by adding the `Explosive` component to the GameObject.

{% hint style="info" %}
The field "Type" has been removed and is no longer available in newer version of FPSF.
{% endhint %}

<figure><img src="/files/Fp0Qbwc3Mj2kqbCwrwuU" alt=""><figcaption></figcaption></figure>

To begin adjusting the explosion range and debugging, scroll to the bottom of the `Explosive` component and enable the **Debug** option. Then, activate **Ranges** and **Rays** to visualize the explosion parameters in the scene.

<figure><img src="/files/gTyRBx1GD8Twv3JLw8u3" alt=""><figcaption></figcaption></figure>

The red range represents the **Death Range**, which you can find at the top of the `Explosive` component. Any object within this range will have its health instantly set to 0. The blue range applies damage based on the distance between the explosion center and the target closer targets receive more damage.

{% hint style="info" %}
The damage range applies damage based on the value set in the **Damage** field of the `Explosive` component. The closer an object is to the explosion's center, the more damage it receives, up to the maximum defined by this field.
{% endhint %}

## Triggering

At this stage, the explosive is set up and capable of dealing damage, but it won’t detonate on its own it needs a trigger.&#x20;

### Triggering With Damage

To make the explosive react to bullets or other damage sources, enable the **Damageable** option in the `Explosive` component. This allows it to explode when it takes damage.

<figure><img src="/files/QaV6uinfo5ZCzBxx0KtM" alt=""><figcaption></figcaption></figure>

Once the **Damageable** option is enabled, the explosive will take damage from any weapon or damaging source. If its health reaches zero whether from gunfire or nearby explosions it will automatically detonate.

### Triggering After Delay

To make the explosive detonate after a delay, similar to a triggered grenade:

1. **Enable Explode After Delay**\
   In the `Explosive` component, check the **Explode After Delay** option.
2. **Set the Delay Time**\
   Adjust the delay time at the top of the `Explosive` component to determine how long after activation the explosion will occur.

This will trigger the explosion automatically when the game starts, with the specified delay before detonation.

<figure><img src="/files/3WMrVrjuAMyRoFe0QOaO" alt=""><figcaption></figcaption></figure>

## Adding Effects

To add an explosion effect that spawns when the explosive detonates:

1. **Assign Explosion Effect**\
   In the `Explosive` component, locate the **Explosion** field.
2. **Link the Effect**\
   Drag and drop the desired explosion effect (such as a particle system or prefab) into the **Explosion** field.

This will ensure the explosion effect is triggered when the explosive detonates.

{% hint style="info" %}
You can find default explosion effects at `FPS Framework > Prefabs > Particle Systems`
{% endhint %}

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

The same steps apply to adding a **Crater Decal**, with a slight difference in how it spawns:

1. **Assign Crater Decal**\
   In the `Explosive` component, locate the **Crater Decal** field.
2. **Link the Decal**\
   Drag and drop the desired crater decal (usually a burned ground effect) into the **Crater Decal** field.
3. **Spawning Behavior**\
   The crater decal will be spawned on the bottom surface of the explosion, creating a realistic burned ground effect where the explosion occurs.

<figure><img src="/files/bhzc9javIvDEQdE7NHXh" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
You can find default Crater Decal effect at `FPS Framework > Prefabs >`Explosive
{% endhint %}

### Audio Effects

This explosive also includes an additional feature that temporarily muffles the player's hearing after detonation. This effect reduces the sound levels for a fixed duration before returning to normal.

By default, this feature is enabled in all default explosives, but it is **disabled** in the `Explosive` component itself by default. To activate it, simply enable the **Muffle Hearing** option in the `Explosive` component.


---

# 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://akila.gitbook.io/fps-framework/tutorials/character/explosive.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.
