# Prevent gun clipping through walls

The JU TPS has a system that prevents gun clipping through walls, and it works very simply

<figure><img src="/files/KwAjlKpCNFz7wD1xH4Z8" alt="" width="360"><figcaption></figcaption></figure>

## Prevent Gun Clipping Script

This script uses a additional **Wielding Position ID** from the [**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) to adjust the weapon's position to avoid clipping through walls.  This script must be added to each weapon individually.

<div align="center"><figure><img src="/files/IRzkjU8j0SkmXsbXakxy" alt=""><figcaption></figcaption></figure></div>

| Parameters                         | Description                                                                                                                                                                                                                                         |
| ---------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| To Up Direction Wielding ID        | Basically it is the ID in the[ **Item Aim Rotation** ](/ju-tps-documentation/game-development/how-to-use-inventory-and-add-items/how-to-align-weapon-rotation.md#item-aim-rotation-center-align)Center that prevents the gun clipping through walls |
| Ray Distance                       | Distance from [**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) to the tip of the gun barrel                                 |
| Block Gun Fire On Prevent Clipping | Makes it impossible for the character to shoot while preventing the weapon from clipping through walls                                                                                                                                              |
| Walls Layers                       | Layers that the Raycast will detect walls                                                                                                                                                                                                           |
| On Prevent                         | Unity Event that is called when a wall is detected                                                                                                                                                                                                  |
| On Stop Prevent                    | Unity Event that is called when a wall stops being detected                                                                                                                                                                                         |

## Creating a Prevent Gun Clipping Wielding Position Reference

The image below shows what a **Wielding Position Reference** should look like to prevent gun clipping.

You can create adjustments that prevent gun clipping individually per weapon, just create new **Wielding Position References** and adjust the position, that should be close to the body and pointing in a direction other than forward, and then write the **Switch ID** in the first parameter of the **Prevent Gun Clipping Script**

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


---

# 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/prevent-gun-clipping-through-walls.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.
