> For the complete documentation index, see [llms.txt](https://docs.bestway.com.ua/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bestway.com.ua/modeling/vehicle-model-setup-pipeline/bone-hierarchy-in-vehicle-models/gun.md).

# 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="https://2358506489-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2UV9d5d9aTZPISbocWyo%2Fuploads%2Fyohs0XXDDDGaCo4OUFBW%2FGun.png?alt=media&amp;token=ba6a6253-b703-4e5d-9f88-922732c27d83" 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="https://2358506489-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2UV9d5d9aTZPISbocWyo%2Fuploads%2F4YElosEr3luqPsZRLtgn%2Fimage.png?alt=media&amp;token=a23fc9a0-d26b-4476-b51b-3f843878133c" 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
