> For the complete documentation index, see [llms.txt](https://docs.twgamesdev.com/uhfps/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.twgamesdev.com/uhfps/integrations/emerald-ai-3.0.md).

# Emerald AI 3.0

{% hint style="info" %}
The integration of UHFPS into Emerald AI is quite straightforward. All you have to do is replace the **Emerald AI Player Damage** script with a modified script and add the **Emerald AI UHFPS Component** to the Emerald AI character.
{% endhint %}

1. Navigate to the **Integrations** folder in the **UHFPS** folder and import the content from the <mark style="color:red;">**Emerald AI - Integration**</mark> package into the project. This should replace the player damage script and import the **Emerald AI Integration** folder into your project.

<figure><img src="/files/5lEHMHzlbSjC0qOqv6Go" alt=""><figcaption></figcaption></figure>

If the **EmeraldAIPlayerDamage** script is not modified, just put this damage function in it. The script can be found here: **Emerald AI\Scripts\Components\EmeraldAIPlayerDamage.cs**

```csharp
public void SendPlayerDamage(int DamageAmount, Transform Target, EmeraldAISystem EmeraldComponent, bool CriticalHit = false)
{
    // The rest of the Emerald AI code here...
    
    //Sends damage to another function that will then send the damage to the UHFPS player.
    DamageUHFPSPlayer(DamageAmount, Target);
}

void DamageUHFPSPlayer(int DamageAmount, Transform Target)
{
    if(TryGetComponent(out PlayerHealth playerHealth) && !playerHealth.IsDead)
    {
        playerHealth.OnApplyDamage(DamageAmount, Target);
        IsDead = playerHealth.IsDead;
    }
}
```

2. Place **EmeraldAI\_UHFPSComponent** to the **Emerald AI** character object. This will ensure that the player will be able to damage the Emerald AI character.

<figure><img src="/files/2uti19Ybn4HnuKs79ZBK" alt=""><figcaption></figcaption></figure>

3. It will be necessary to modify the Emerald AI tags and layers to use those from the UHFPS. First, change the Tag to **Flesh** and the Layer to **BodyPart**.

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

4. Go to **Detection & Tags -> Tag & Faction Options -> Tag Options** and change **Emerald Unity Tag** to **Flesh** and **Detection Layers** to **Player**.

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

5. Finally, add the **Target Position Modifier** component to the **HEROPLAYER** object and set the **Height Modifier** to 1.7. This will ensure that the Emerald AI raycast detection will be directed at the player's head instead of the player's pivot position.

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

Unity Asset Store link to the **Emerald AI 3.0** asset page:

{% embed url="<https://assetstore.unity.com/packages/tools/behavior-ai/emerald-ai-3-0-203904>" %}
