# Сhassis mechanisms

## Chassis Mechanisms in GEM RTS

In GEM RTS, chassis mechanisms are used to control the movement and physical behavior of `vehicle`-type units.&#x20;

**Chassis Mechanisms for Ground Vehicles**

These mechanisms enable movement and control for wheeled or tracked units:

* `roller`&#x20;
* `roller_joint`
* `align`
* `wheel`&#x20;
* `track`&#x20;
* `steer`&#x20;
* `trailer`&#x20;
* `steam piston`

**Chassis Mechanisms for Aircraft**

These mechanisms control the aerodynamic elements of an aircraft:

* `flap`
* `rudder`
* `aileron`
* `elevator`

***

## Preliminary Notes

{% hint style="warning" %}
All bone names and associated parameters must be checked for compliance with **internal standards**. This ensures the **correct operation** of the mechanism in the game engine.
{% endhint %}

In **GEM RTS**, different chassis mechanisms are used depending on the suspension type. \
Tracked vehicles use either the **Roller-Lever (roller + roller\_joint)** or **Roller-Rocker (roller + align)** mechanism.

## **Roller-Lever**

**Functionality**\
During unit movement, each roller is placed on the ground by rotating the **IK bone** so that the roller (wheel) maintains contact with the **ground surface**.

**Bone naming rules**\
All roller bones must start with the prefix `roller`.

<table><thead><tr><th width="216">Bone Name</th><th>Description</th><th>Internal Parameters</th></tr></thead><tbody><tr><td><code>roller&#x3C;N>_joint</code></td><td>Bone containing the <strong>suspension mesh</strong>. <br>Works under <strong>Inverse Kinematics (IK)</strong> rules.</td><td><code>poly</code>, <br><code>IKType=revolute</code>, <br><code>IKMin=&#x3C;value></code>, <br><code>IKMax=&#x3C;value></code></td></tr><tr><td><code>roller&#x3C;N></code></td><td>Support bone for the <strong>roller/wheel</strong>.</td><td><code>radius=&#x3C;value></code></td></tr></tbody></table>

{% hint style="success" %}
The index `N` of a `roller` bone must match the index `N` of the `roller_joint` bone to which the `roller` is linked. Example:

* `rollerL1` must be linked to `rollerL1_joint`.
* `rollerR1` must be linked to `rollerR1_joint`.
  {% endhint %}

**Bone features**

* The `roller<N>_joint` bone is positioned at the **pivot axis** of the lever, to which the `roller<N>` bone is attached. The **Z-axis** of `roller<N>_joint` must align with the **lever’s rotation axis**.
* **Roller radius**: The `radius` parameter is defined in **meters**.

{% hint style="warning" %}
The roller’s radius should be **slightly larger** than the visible roller radius in the model to account for the **track thickness**. Otherwise, visually, the roller will **sink into the track**.
{% endhint %}

***

## **Roller-Rocker**

**Functionality**\
This mechanism functions like **a seesaw**. The chassis tries to align two bones with defined **radii** to the ground by rotating the main bone under **Inverse Kinematics (IK)** rules.

**Bone naming rules**\
All alignment bones must start with the prefix `align`.

<table><thead><tr><th width="199">Bone Name</th><th width="294">Description</th><th>Internal Parameters</th></tr></thead><tbody><tr><td><code>align</code></td><td>Bone containing the <strong>suspension mesh</strong>. Works under <strong>IK</strong> rules.</td><td><code>poly</code>, <br><code>IKType=revolute</code>, <br><code>IKSpeed=&#x3C;value></code>, <br><code>IKMin=&#x3C;value></code>, <br><code>IKMax=&#x3C;value></code></td></tr><tr><td><code>roller</code></td><td>Support bone for the <strong>roller/wheel</strong>.</td><td><code>radius=&#x3C;value></code></td></tr></tbody></table>

**Bone features**

* Two child bones act as **support points**, which must ultimately align with the ground.

***

## **Wheel**

**Functionality**\
Rotates bones based on the **wheels’ movement** relative to the ground.

**Bone naming rules**\
All wheel bones must start with the prefix `wheel`.

**Internal Parameters**

* The `radius` parameter defines the **wheel radius in meters**.

{% hint style="info" %}
If all wheels are identical, the default wheel radius can be set in the `basis` bone using the `wheelradius` parameter.
{% endhint %}

***

## **Track**

**Functionality**\
Track movement is **simulated** by shifting the **V texture coordinate** of the track according to the **unit's movement**.

**Internal Parameters**\
Track settings are defined in the **.def model file**:

* `bone` – name of the **track bone**.
* `length` – length of the track in **meters**.

***

## **Steer**

**Functionality**\
Steering is controlled by setting the **rotation angle** on the **IK bone**.

**Bone Naming Rules**\
All **steering bones** must start with the prefix **`steer`**.

**Internal Parameters**\
Inverse Kinematics parameters:

```plaintext
IKType=revolute, 
IKSpeed=<value>, 
IKMin=<value>, 
IKMax=<value>
```

***

## **Trailer**

**Functionality**\
The **trailer mechanism** works similarly to **artillery pieces attached to a tractor**. It **rotates the pivot bone** to ensure the **support bone** remains stationary, ensuring stability and correct movement behavior.

**Bone Naming Rules**

| **Bone Name**         | **Description**                                                                                                             | **Internal Parameters**                                                                                                  |
| --------------------- | --------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `trailer`             | Support bone. In the bone hierarchy, it is linked to the pivot bone.                                                        | `poly`                                                                                                                   |
| `<trailername>_joint` | Pivot bone defining the **rotation point** of the hitch. Positioned at the **hitch’s rotation axis** in the bone hierarchy. | <p><code>poly</code>, <br><code>IKType=revolute</code>, <code>IKMin=\<value></code>, <br><code>IKMax=\<value></code></p> |

**Bone features**

* **Pivot Bone Positioning**\
  The `<trailername>_joint` bone must be placed **at the hitch’s rotation axis**, where the trailer connects in the **bone hierarchy**.
* **Pivot Bone Orientation:**
  * The **Z-axis** must align with the **hitch’s rotation axis**.
  * The **X-axis** must be directed towards the **support bone** to **prevent lateral displacement** in the rotation plane. Other minor displacements are allowed.

***

## **Steam Piston**

**Functionality**\
Designed specifically for **steam locomotives**, aligning the **piston’s movement** with the **wheels’ rotation**.
