This page covers the integration of Emerald AI and Game Kit Controller.
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.
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
Follow these easy steps to get your Emerald AI NPC setup to work with GKC.
Select the NPC with the Emerald AI component attached and change it's Unity tag to enemy.
Next change the layer of the NPC to npc.
If you receive a popup from Unity with the following "Do you want to set layer npc for all child objects as well?" Press the No, this object only button.
In the Emerald AI System component go to the Detection & Tags tab and select Tag Options.
Change the Emerald Unity Tag field to enemy.
Then under Detection Layers select player and npc, and deselect anything else, unless it's needed for other parts of your project.
That's it for inspector setting changes, next you'll need to make some script changes as outlined below.
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:
Then in the same file, add the following inside the SendPlayerDamage
method:
You can now save the EmeraldAIPlayerDamage.cs
script and move onto the next step below.
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:
After changing the script inheritance, and in the same script add the following code after the SendEmeraldDamage()
method:
Wait! Before you go further, this is not the best way to integration Emerald AI with GKC. Please consider using the recommended method in the first tab.
Open the applyDamage.cs
script found in the the Game Kit Controller directory Assets/Game Kit Controller/Scripts/Health
in your favourite editor.
First at the top of the script you'll see a few namespaces being included in the script (before the class definition), after the last one add using EmeraldAI;
so that the script now looks something along the lines of:
After adding the EmeraldAI
namespace to the top of the script you will need to uncomment the Emerald AI specific code at the bottom of the checkHealth()
and checkCanBeDamaged()
methods and save the script.
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*
That's it! If you followed all of the above and uncommented the Emerald AI code then Game Kit Controller is now integrated with Emerald AI in your project