# Using an Attract Modifier

## Using an Attract Modifier

The Attract Modifier will attract AI that are within range and invoke the "Attract Reaction". The object the Attract Modifier is attached to will be the source of attraction. This system is intended to extend the functionality of the Sound Detector Component by allowing certain objects, collisions, and custom calls to attract nearby AI.

<figure><img src="https://4021441153-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv03IiZPaMe8fX49a9MnO%2Fuploads%2FLaDEucbgp53dh6npDPf8%2FUsingAnAttractModifier.gif?alt=media&#x26;token=4aeaf067-609d-4b16-8e3e-f859f6879480" alt=""><figcaption></figcaption></figure>

### Step 1

Find the AttractModifier script by searching for AttractModifier within the Project tab. Drag and drop it on the object you'd like to have attract AI (stone, box, etc.).

<figure><img src="https://4021441153-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv03IiZPaMe8fX49a9MnO%2Fuploads%2Ff2NZafwpmNxNeSRl44cY%2FAddingAnAttractModifier.gif?alt=media&#x26;token=4fa99018-60da-44df-8043-88ec18c5aca9" alt=""><figcaption></figcaption></figure>

### Step 2

After you have added an AttractModifier to your object, you will need to specify your Emerald AI Layer. When the AttractModifier is triggered, it will send information to all detected AI with this layer that are in range, but only to the Emerald AI Layer.

<figure><img src="https://4021441153-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv03IiZPaMe8fX49a9MnO%2Fuploads%2FBm83CuYYal7122eB3P3Y%2FStep2AttactModifier.png?alt=media&#x26;token=d171aaf2-18a5-4466-af47-8a3bb04e5eb1" alt=""><figcaption></figcaption></figure>

### Step 3

Next, you will need to assign a Reaction Object. For this tutorial, just use the included Move To Attract Source (Attract Modifier) example.

<figure><img src="https://4021441153-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv03IiZPaMe8fX49a9MnO%2Fuploads%2FaFEf5VxUj6EF6rnXV9jU%2FStep3AttactModifier.png?alt=media&#x26;token=b8ad9eeb-ec04-4f73-8c4c-112f953fc06a" alt=""><figcaption></figcaption></figure>

### Step 4

Adjust the Attract Modifier settings as needed. There are options to have the Attract Modifier triggered OnStart, OnTrigger, OnCollision, and with a custom call. Ensure you have a [Rigidbody Component](https://docs.unity.cn/560/Documentation/Manual/class-Rigidbody.html) on your game object if your Attract Modifier will be using OnTrigger or OnCollision.

<figure><img src="https://4021441153-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv03IiZPaMe8fX49a9MnO%2Fuploads%2FJEJICISYZZZiHQRgugzp%2FStep4AttactModifier.png?alt=media&#x26;token=aa7ffb07-1253-4073-8610-e69035d0a4f2" alt=""><figcaption></figcaption></figure>
