Emerald AI

This page covers the integration of Emerald AI and Game Kit Controller.

What is Emerald AI?

Emerald AI allows developers to quickly create engaging dynamic AI with 100's of AAA quality features, all without having to write a single line of code! Emerald's editor is designed to make creating AI easy, yet incredibly customizable. Emerald caters to all kinds of developers and offers everything users would expect from an all-in-one AI system.

You can find more information about Emerald AI, and its documentation and also purchase it over on the Unity Asset Store.

Inspector Settings

Black Horizon Studios (The maker of Emerald AI) has a tutorial video showing the inspector changes needed to integration Emerald AI and Game Kit Controller.

If you'd rather just get a step by step instructions for the inspector changes you can view these in the tab below labelled "Step by Step Instructions".

While the video also covers the code changes, these are now outdated (as of GKC v3.03-1+), you can find the up to date code changes needed below

Script Changes

Part #1

First you'll need to open the EmeraldAIPlayerDamage.cs script found in the Emerald AI directory Assets/Emerald AI/Scripts/Components/ in your favourite editor and add the following code after the DamagePlayerStandard() method:

/// <summary>
/// Applies damage to a Game Kit Controller controlled player.
/// </summary>
/// <param name="DamageAmount">The amount of damage to deal to the GKC player.</param>
void DamageGameKitController(int DamageAmount, GameObject attacker)
{
    applyDamage.checkToDamageGKCCharacterExternally (DamageAmount,
    gameObject, attacker);
}

Then in the same file, add the following inside the SendPlayerDamage method:

// Send damage to GKC player
GameObject targetObject = null;

if (Target != null){
    targetObject = Target.gameObject;
}

DamageGameKitController(DamageAmount, targetObject);

You can now save the EmeraldAIPlayerDamage.cs script and move onto the next step below.

Part #2

The next part can be done in two ways, the first is the recommended way to add the integration. The second option isn't recommended but can be used if you don't want to use inheritance.

Open the EmeraldAISystem.cs script found in the the Emerald AI directory Assets/Emerald AI/Scripts/System in your favourite editor.

First at the top of the script where the class is defined you need to replace MonoBehaviour inheritance with healthManagement - At the time of writing this at line 20. The class definition should then look like the following:

public class EmeraldAISystem : healthManagement

After changing the script inheritance, and in the same script add the following code after the SendEmeraldDamage() method:

/// <summary>
/// Game Kit Controller Integration
///
/// Applies damage to the player via the GKC healthManagement class.
/// </summary>
public override void setDamageWithHealthManagement(float damageAmount,
    Vector3 fromDirection, Vector3 damagePos, GameObject attacker, GameObject projectile,
    bool damageConstant,
    bool searchClosestWeakSpot, bool ignoreShield, bool
    ignoreDamageInScreen, bool damageCanBeBlocked, bool
    canActivateReactionSystemTemporally, int damageReactionID, int damageTypeID)
{
Damage((int)damageAmount, EmeraldAISystem.TargetType.Player);
}

That's it! Congratulations, Game Kit Controller is now integrated with Emerald AI in your project 🥳🙌

Now you can hunt that T-Rex down and it'll no longer be invincible to your attacks... although neither will you... *PEW* *PEW* 🦖🔫

Last updated