# Ballistic Surfaces - Penetration

{% hint style="warning" %}
We have modified our cube's position in previous tutorials, so let's put it back to **0,2,10** before continuing here. Also, make sure our **main camera'**&#x73; **field of view** is set back to **60.**
{% endhint %}

When you want any of the objects in your scene to be penetrable by bullets, you need to attach **BallisticSurface.cs** script onto your objects. Let's add this component to our cube object in the scene.

![BallisticSurface.cs component on the cube object.](/files/-MaKdHjtRwR8yDIk-Q6h)

You can use the **Preset** drop-down to select various different surface presets. For the sake of the tutorial, we will use the **Custom** preset, and adjust the variables ourselves. For this tutorial, we are only interested in penetration, so go ahead an uncheck the **Ricochet Enabled** checkmark. When a bullet starts penetrating a surface, it will lose it's kinetic energy depending on the **Energy Consumption** slider. Here, a value of 1.0 means losing 100% of the bullet's kinetic energy, while 0.0 means losing none. **Min Energy** denotes the minimum kinetic energy a bullet should have in order to be able to start penetrating this object. **Deflection Angles** two-ended slider allows us to define an angle range, which will be used to select a random exit angle for the bullet. Let's leave the settings like this for now, except that we have unchecked **Ricochet Enabled** mark, so it will look like this:

![](/files/-MaKe55lGVb75swstc77)

If you play the game and hit space now, you will see that the bullet will penetrate the object.

![Bullet raycast penetrating the object. Blue line shows a PenetrationInHit, meanwhile cyan line shows a PenetrationOutHit.](/files/-MaKeGNh2_YMqW5tdekl)

More the bullet ray stays inside the object, more kinetic energy it will lose, depending on the **Energy Consumption**. So, object's thickness will affect how the bullet penetration continues. Go ahead and change our cube's scale to 6 in Z axis, so it's scale will be 5,6,6. Then play the game, hit space bar. You will see that the bullet still penetrates, but loses so much of it's kinetic energy that it basically falls into the ground right after exiting the object.

![Bullet ray still penetrating when the object is thicker, but falling right after to the ground (green hit line).](/files/-MaKf0lpT_1S4i5FEj2k)

If you were to further increase Z axis scale, say to 8, then the bullet ray would not get out of the object. Also, the thickness doesn't have anything to with the actual Z scale of the object. So, say you set the Z scale to 8, preventing the bullet from penetrating. But if you moved the cube to such a position that the bullet should enter from not-so-thick part of the cube, it would still penetrate.

![Still penetrating because ray hits such an angle that the it could get out before losing too much energy.](/files/-MaKi5V_palzof-5isOD)

Of course you can tweak this behavior completely to your liking by changing the **Energy Consumption** value. Finally, let's change the **Deflection Angle** value, to be somewhere between 50 and 60.

![Deflection angles set to 50-60 range.](/files/-MaKh0C2cvruYywF1KuL)

Now if we were to fire multiple shots continuously, we would see that they would be deflecting from the linear path randomly according to the deflection angles.

![Multiple shots fired continuously, after penetrating the rays are deflected.](/files/-MaKgwa58pKoAoGRLifx)

Now let's take a look at the **Ricochet** settings to see how the bullet rays would ricochet off the surface.


---

# 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://rsb.inanevin.com/getting-started/ballistic-surfaces-penetration.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.
