> For the complete documentation index, see [llms.txt](https://vinipistudios.gitbook.io/procedural-first-person-toolkit/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://vinipistudios.gitbook.io/procedural-first-person-toolkit/component-reference/procedural-motion-component/creating-custom-procedural-motions.md).

# Creating Custom Procedural Motions

A technical guide for developers on how to inherit from the **ProceduralMotionComponent** base class and override the necessary functions to create unique, project-specific movement logic.

For this example, we are going to use the demo project and implementing Ready Or Not's ready/unready state, where by pressing a button the player lower's their equipment, allowing for faster movement.

**Final Result:**

{% embed url="<https://youtu.be/Ictw8P2MbKE>" %}

### 1. Creating the Preset

* Right click on an empty space inside the content browser.
* Click **BlueprintClass.**
* Select **ProceduralPreset** as the base class.

Let's call it **BP\_ProceduralPreset\_Unready**.

<div align="left"><figure><img src="/files/epIehATPcxK3Rp1SrDsJ" alt=""><figcaption></figcaption></figure></div>

* Create 4 variables, one for the Rotation and one For the Location offset, both for first and third person.

<div align="left"><figure><img src="/files/omaBKuGKTZG5Ttw6IwhH" alt=""><figcaption></figcaption></figure></div>

### 2. Creating the Component

* Right click on an empty space inside the content browser.
* Click **BlueprintClass.**
* Select **ProceduralMotionComponent** as the base class.

<div align="left"><figure><img src="/files/o3ZzGrozRXYSjBZRnYPN" alt=""><figcaption></figcaption></figure></div>

Lets call it **B\_ProceduralUnreadyMotionComponent**.

### 3. The Procedural Motion Output

* Inside your newly created component, override the function called **ComputeOutput**.
* Create a **Bool** variable to define the current Ready/Unready state (make sure it's default value is true).
* Create a **Float** variable to define the actual unready alpha.

<div align="left"><figure><img src="/files/yKeA4kQBzoEg0yGc7aaV" alt=""><figcaption></figcaption></figure></div>

* Create a new function called **RefreshAlpha**, passing in **DeltaTime** as a parameter
* Use a simple **interpolation** algorithm to smoothly transition between ready/unready.

<div align="left"><figure><img src="/files/VIvuqc5608CgsnHJJ3PY" alt=""><figcaption></figcaption></figure></div>

* Make sure **RefreshAlpha** is called inside **ComputeOutput**

<div align="left"><figure><img src="/files/BNzA54AwmmmqKLq8roP0" alt=""><figcaption></figcaption></figure></div>

* Call **GetPreset,** passing in the parent's **PresetData** variable and our newly created preset class, and promote the **ReturnValue** to a variable called **Preset.** connect the **IsValid** pin to a return node.

<div align="left"><figure><img src="/files/30mRw4QszgeGcah1ANHm" alt=""><figcaption></figcaption></figure></div>

* Create a **Branch**, passing in **FirstPerson** (from the input) as the condition.

<figure><img src="/files/PZKpo0N99UpIUU4jiBo7" alt=""><figcaption></figcaption></figure>

* From the **True** pin, call a return value, making a procedural output based on the FP location and rotation from our preset, passing in **UnreadyAlpha** as the **Weight**, and **Bone** as the **Space,** and **Additive** as the **Composition**.

<figure><img src="/files/i0epVYljy70G0Kci3tMI" alt=""><figcaption></figcaption></figure>

* From the **False** pin, duplicate the previous code, this time passing in the **Third Person** values.

<figure><img src="/files/12i2ZSYdrVcbtOkAT3fq" alt=""><figcaption></figcaption></figure>

* Duplicate the **ReturnNode,** passing in Return Value as false if the preset is invalid.

<div align="left"><figure><img src="/files/BtVssoltT5e3Mg1t3T0A" alt=""><figcaption></figcaption></figure></div>

This should be everything for the component.&#x20;

<a href="https://blueprintue.com/blueprint/lv9bmz04/" class="button primary">See the Final Code</a>

### 4. Adding the Component

For this example, let's add the component to our character blueprint.&#x20;

{% hint style="success" %}
The component could also be added to the equipment, but to make things easier, let's add it to the character.
{% endhint %}

* Add **BP\_ProceduralUnreadyMotionComponent** to your character and select a **PresetData** containing the preset created previously, I'll be using the AK preset to speed things up, but you could create one for the character or each of the weapons.

<div align="left"><figure><img src="/files/Tl9YCFYf3VL6cY11ztlX" alt=""><figcaption></figcaption></figure> <figure><img src="/files/alXJkiGmxLSk6XLgC3gf" alt=""><figcaption></figcaption></figure></div>

* Swap the ready state based on input.

  <figure><img src="/files/e0vUzTOZcPrSB5DVudwU" alt=""><figcaption></figcaption></figure>

### 5. Final Result

<figure><img src="/files/QeJ8CuP0refO2RaAK4yI" alt=""><figcaption></figcaption></figure>

Feel free to copy the values from the screenshot or find your own.
