# Patches

## Patch Objects

To follow this tutorial you can use the following Blender file that contains all the geometry necessary to create new patches on your own (either by swapping the textures of this sample or creating your own shape geometry). This tutorial will not teach you how to UV and texture, so pre-existing knowledge of these topics is required.

{% file src="<https://370758970-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVykVVurkMJOzqmISKydU%2Fuploads%2Fgit-blob-459c06ac1c1a81d548756d3576fe3d5c4407fc86%2Frhs_patch_sample.blend?alt=media&token=c1c94ac9-9938-4e86-ae0f-951f979b7e61>" %}

When you open the file you will see the following:

<figure><img src="https://370758970-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVykVVurkMJOzqmISKydU%2Fuploads%2Fgit-blob-fa84d0bde608e6b552705993ed86f91d535f58db%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

The highlighted object is the patch geometry, and the purple box is the collider. You can leave the collider as is.

Patches in RHS follow very simple rules:

* No bones or rigging necessary
* The world origin must be at backside (velcro) of the patch center

<figure><img src="https://370758970-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVykVVurkMJOzqmISKydU%2Fuploads%2Fgit-blob-344878c2fb8da8f4cf75b904ae327613aeec1f53%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

* The patch must be facing in the direction of Y+ axis

<figure><img src="https://370758970-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVykVVurkMJOzqmISKydU%2Fuploads%2Fgit-blob-d7bd3e369a9caac1099045e479f632f8b6ddee9d%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

* You can use morphs to make them fit the curvature of the objects they are attached to.

### Morph Targets

In order to ensure the curving of the patch on rounded objects such as helmets and sleeves, you can add a "Curve" shape key and modify the geometry to fit with the sample above. The **Curve** key at 1.0 setting is the maximum curvature. The **Basis** key should represent your patch in fully flat position.

<figure><img src="https://370758970-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVykVVurkMJOzqmISKydU%2Fuploads%2Fgit-blob-9de05af9fb835d31cc8d86b8e7f56df49e3d01c7%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

When you are importing your FBX into Workbench, make sure the Export Morphs import setting is enabled.

<figure><img src="https://370758970-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVykVVurkMJOzqmISKydU%2Fuploads%2Fgit-blob-80b64e74b89481705cc25074764c535280baf8fe%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

You will then be able to control the morph in the xob editor, but you can leave it at 0:

<figure><img src="https://370758970-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVykVVurkMJOzqmISKydU%2Fuploads%2Fgit-blob-8671fbb2d577ddaef96a054926810be36eccde88%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

### Prefab

While you are making your own mod with RHS: Status Quo as dependency, find **Patch\_Base.et** in SQ and right click on it. Select "Inherit in 'MyNewPatchMod'". This should prompt you to create a new inherited prefab in your own mod. Edit this prefab.

In the **InventoryItemComponent** change the **Name** and **Description** values.

<figure><img src="https://370758970-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVykVVurkMJOzqmISKydU%2Fuploads%2Fgit-blob-7c0f32656b21e5b44bffc6b070c2dd01240cdb01%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

In the **MeshObject** component set the **Object** value to your newly created xob.

{% hint style="info" %}
NOTE: If you are just changing textures and using the same mesh for the patches, then just change the material. You dont need a new xob for every patch.
{% endhint %}

<figure><img src="https://370758970-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVykVVurkMJOzqmISKydU%2Fuploads%2Fgit-blob-ce9e40071f6660d1c2a81e635c0d849a4dba2df1%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

In the **BaseLoadoutClothComponent** change the material overrides like shown below to your new materials. Change the **Area Type** value if necessary (just filter for Velcro to find all RHS velcto area types) depending on the general size of your patch.

<figure><img src="https://370758970-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVykVVurkMJOzqmISKydU%2Fuploads%2Fgit-blob-e6e374fa876e632fff6045cda071d1ac0c263f0b%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

Your patch is now ready to be accepted on RHS patch system compliant cloth items.

## Receiving Objects

If you are setting up cloth items that should receive patches there are a few steps that are different for objects like Helmets, Jackets and Vests, because they interact with the AR inventory system differently.

{% hint style="warning" %}
The simplest approach for any item type is to **inherit** from a pre-existing RHS object that most closely resembles your new object.
{% endhint %}

### Headgear

First add a **RHS\_ClothNodeStorageComponent** and set it up in a similar fashion, changing values where appropriate:

<figure><img src="https://370758970-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVykVVurkMJOzqmISKydU%2Fuploads%2Fgit-blob-04b4b5c6c842ea423b09ae6a6d594ff6963687a8%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

In the **BaseLoadoutClothComponent** make sure you have **Debug Worn Model** value set to true when editing positions of velcro attachment slots.

{% hint style="info" %}
Do not forget to turn **Debug Worn Model** to off when you are done editing.
{% endhint %}

<figure><img src="https://370758970-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVykVVurkMJOzqmISKydU%2Fuploads%2Fgit-blob-5fea4731728f0810b65176a4f4c73fab9cbc556b%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

In the **Slots** array of **BaseLoadoutClothComponent** make an new slot of type **RHS\_LoadoutSlotInfo**. The name of the slot MUST be one of the following (Top Velcro, Left Velcro, etc.). If you name it wrong it will not work:

<figure><img src="https://370758970-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVykVVurkMJOzqmISKydU%2Fuploads%2Fgit-blob-9fa23b6e6b45753eb935db9594a71f8e263fed68%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

Use the following reference to set up the slot:

<figure><img src="https://370758970-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVykVVurkMJOzqmISKydU%2Fuploads%2Fgit-blob-eb1e61a7e60eef01ada097c42312a8bea01c869e%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

The **Offset and Angle** properties should be used to align the patch positioning. Load a patch prefab into the **Prefab** property to see it while modifying position:

<figure><img src="https://370758970-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVykVVurkMJOzqmISKydU%2Fuploads%2Fgit-blob-0607a42678a87cfae13e31f037cb3c380137f770%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

Set the Name and Area Type settings appropriate for your patch attachment (name must be same as the slot name and area type must be one of the RHS velcro slot areas). Use morph settings to indicate how much the patch should bend if it has morphs:

<figure><img src="https://370758970-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVykVVurkMJOzqmISKydU%2Fuploads%2Fgit-blob-bf745910593817f1b912b8a7bf9271bbff2dd002%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

**Morph Value** setting indicates by how much between 0 and 1 the patch will bend.

### Vests

For armored vests the setup is exactly the same as for helmets but the name of the slot should be **ChestVelcro**.

### Jackets

For jackets and other upper torso objects, the component structure is a little bit different:

<figure><img src="https://370758970-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVykVVurkMJOzqmISKydU%2Fuploads%2Fgit-blob-c2974bccaaf8205118b09d5e2c17adebcb59a4ed%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

The **RHS\_ClothNodeStorageComponent** must be setup with above settings as a child of **SCR\_UniversalInventoryStorageCOmponent** that is setup as follows:

<figure><img src="https://370758970-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVykVVurkMJOzqmISKydU%2Fuploads%2Fgit-blob-b039a30ea0b6b7fda7658b83b601b4d434f10e62%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

The **BaseLoadoutClothComponent** is then setup ehactly the same way as for the Headgear:

<figure><img src="https://370758970-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVykVVurkMJOzqmISKydU%2Fuploads%2Fgit-blob-c9c769a44adf6e732db53c9e378c438fffa7e8fe%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

Note that the slot names **SleeveRight and LeftVelcro** must be maintained for it to work.
