# Adding Engine Sound

## Engine Sound Guide

{% embed url="<https://www.youtube.com/watch?v=H2GNc3_7GcA>" %}

### 1. Add Vehicle Engine Sound Manager component

<div align="left"><figure><img src="https://3780384024-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPyvySfaC85jUgVcDPRJ%2Fuploads%2FXlsChvZQdN56suJSJJlm%2Fimage.png?alt=media&#x26;token=458dfb98-8072-4c3d-af10-7c8f18b4bdc7" alt="" width="461"><figcaption></figcaption></figure></div>

### 2. Create Engine Sound Scriptable Object

<div align="left"><figure><img src="https://3780384024-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPyvySfaC85jUgVcDPRJ%2Fuploads%2FI2SDgKOKVifcBBRdoEet%2Fimage.png?alt=media&#x26;token=110ad7e4-ea99-4724-8b69-d1e0cd349e3b" alt="" width="563"><figcaption></figcaption></figure></div>

In the folder of your choice open the context menu by clicking RMB, then create a scriptable object instance by navigating Create -> CustomVehicleController-> EngineSoundSO.

### 3. Populate the scriptable object with audio clips.

<div align="left"><figure><img src="https://3780384024-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPyvySfaC85jUgVcDPRJ%2Fuploads%2FzUD6CdRLrOHLTz8Szp0K%2Fimage.png?alt=media&#x26;token=acdc5935-5c08-48f5-8c97-de7ddbd4b308" alt="" width="461"><figcaption></figcaption></figure></div>

You must also specify the rpm step between every audio clip for a smooth transition between clips.

{% hint style="info" %}
Audio clips must be perfectly looped.
{% endhint %}

{% hint style="info" %}
You can easily record engine sound clips using [Ange The Great Engine Simulator](https://github.com/ange-yaghi/engine-sim).
{% endhint %}

{% hint style="info" %}
Here are the recommended audio import settings for the best audio quality.

![](https://3780384024-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPyvySfaC85jUgVcDPRJ%2Fuploads%2FknUPU9cgpjxFjQ5h0zkd%2Fimage.png?alt=media\&token=b422bdba-c012-4fbe-af49-b07a71e45f70)
{% endhint %}

### 4. Assign references to the Vehicle Engine Sound Manager component.

<div align="left"><figure><img src="https://3780384024-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPyvySfaC85jUgVcDPRJ%2Fuploads%2F9rZQw4KlTTTz44f8mf8O%2Fimage.png?alt=media&#x26;token=935e59b2-631f-402a-af71-b38f6556a6f9" alt="" width="449"><figcaption></figcaption></figure></div>

3D Sound settings are the same settings that are on the default AudioSource component.

### 5. Performance modification impact

Version 1.1.0 added engine performance modifications, which can alter the engine's working rpm range. The change in rpm is represented in code and works correctly, but we decided to provide you a choice if you want change the pitch of the sound or not.

<div align="left"><figure><img src="https://3780384024-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPyvySfaC85jUgVcDPRJ%2Fuploads%2FcWBKSof5uvz4X5qXHfm1%2Fimage.png?alt=media&#x26;token=e4a53ac1-38d1-4bfc-94b2-58b0770cad9f" alt="" width="563"><figcaption></figcaption></figure></div>

If you set the "Engine Modifications Affect Pitch" toggle to "True", then the engine sound's pitch will be additionally multiplied by the ratio between the standard engine's rpm and the modified engine's rpm.&#x20;

For example, if the engine has 10000 rpm at maximum by default and gains 2000 rpm from the engine parts, the pitch will be multiplied by 1.2.&#x20;

The "Engine Sound Pitch" works independently from this, so you can modify this value.
