# Gun

## Description of gun elements

The `gun_rot` bone is the parent bone of the weapon and is linked to the `turret` bone.\
This bone operates based on inverse kinematics.

<figure><img src="/files/OQ1ttzCcRdkPMGT9uA6I" alt=""><figcaption><p>Gun component structure</p></figcaption></figure>

<table><thead><tr><th width="171">Name</th><th width="245">Description</th><th>Object Properties</th></tr></thead><tbody><tr><td><code>gun_rot</code></td><td>Responsible for vertical aiming of the weapon. Works based on inverse kinematics.</td><td><code>poly</code><br><code>ID=gun_rot</code><br><code>IKType=revolute</code><br>Defines rotation constraints that limit the elevation and depression angle of the gun barrel.</td></tr><tr><td><code>gun</code></td><td>Simulates the moving part of the tank gun barrel and has an animation.</td><td><code>poly</code><br><code>ID=gun</code><br><code>Animation</code></td></tr><tr><td><code>gun_vol</code></td><td>A volume that covers the visible parts of the <code>gun</code> and <code>gun_rot</code> bones.</td><td><code>volume</code></td></tr><tr><td><code>foresightN</code></td><td>Simulates a machine gun mounted on the gun mantlet.<br><code>N</code> is a number according to the rule that determines the correspondence between the <code>foresight</code> bone number and the type of mounted machine gun.</td><td>-</td></tr><tr><td><code>foresight1</code></td><td>An effector used for spawning the tank gun firing effect.</td><td>-</td></tr></tbody></table>

### Gun element linkage structure

<figure><img src="/files/mu9x77BEuV5kmOJxMbhA" alt=""><figcaption><p>Gun element linkage structure</p></figcaption></figure>

* turret
  * `gun_rot`
    * `gun`
      * `foresight1`
      * `gun_vol`
    * `foresightN`

## Extension for rotational mechanisms

The `bone_rotator` extender is used to implement various aiming mechanisms, particularly for rotational systems in guns and other devices.\
The core principle is to create a connection between two bones using inverse kinematics (IK), ensuring their rotation along the Z-axis.

## Operating principle

The `bone_rotator` extension links two bones, usually named `gun_rotator1` and `gun_rotator2`. These bones function under inverse kinematics rules, creating a "magnetic" attraction effect along the X-axis.\
The engine adjusts the positions of these bones so that their X-axes are aligned toward each other. This technology is particularly useful for implementing telescopic mechanisms (e.g., pistons), where the rotation of one bone depends on the other.

### Bone properties

Bones involved in this mechanism have the same properties as any other IK bones.

| `poly`            | Defines whether the bone is visible.                         |
| ----------------- | ------------------------------------------------------------ |
| `ID`              | Component identifier associated with the extension.          |
| `IKType=revolute` | Specifies the type of inverse kinematics (rotational joint). |
| `IKMin=<value>`   | Minimum rotation limit (if needed).                          |
| `IKMax=<value>`   | Maximum rotation limit (if needed).                          |

**Applications:**

* Telescopic mechanisms
* Pistons
* Other systems with dependent bone rotation


---

# 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://docs.bestway.com.ua/modeling/vehicle-model-setup-pipeline/bone-hierarchy-in-vehicle-models/gun.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.
