# 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="https://2665493337-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fh8bp6Jx5qkS4c0NEaWR1%2Fuploads%2F8QSpGb3OBLLEfeJEy1Ou%2FScreenshot_5.png?alt=media&#x26;token=05ee8d57-11de-4c18-80eb-d2d21bf34c22" 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="https://2665493337-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fh8bp6Jx5qkS4c0NEaWR1%2Fuploads%2Ft87MsXU9KGXQEMr4TZUo%2FScreenshot_6.png?alt=media&#x26;token=15bfcbeb-a741-4015-9cc3-9454a8d618d1" 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="https://2665493337-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fh8bp6Jx5qkS4c0NEaWR1%2Fuploads%2FITUMUNa0a1r44YJdAdW8%2FScreenshot_7.png?alt=media&#x26;token=d8f36d2d-74b9-4307-93ea-23c04d388a43" 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="https://2665493337-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fh8bp6Jx5qkS4c0NEaWR1%2Fuploads%2FCyC5DzwjDirNtelQTXQ9%2FScreenshot_8.png?alt=media&#x26;token=54e7e6a7-4c2a-48f0-8987-c95e927e7c4f" 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="https://2665493337-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fh8bp6Jx5qkS4c0NEaWR1%2Fuploads%2F0bAxWDZUeCbFLS2YFsgg%2FScreenshot_12.png?alt=media&#x26;token=022d83df-2d46-4b04-b116-3c386056464b" 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>" %}
