Accessing the EmeraldAPI Script

Important: It is expected that you have C# coding knowledge before proceeding.

While Emerald AI's API can be accessed per individual component, this method allows users to access all practical API through a single static class called EmeraldAPI. The only reference that is required is an AI’s EmeraldSystem component that's passed through the EmeraldAPI script and to its functions. It is recommended that you use the EmeraldAI namespace at the top of your scripts to make accessing the Emerald AI scripts easier using:

using EmeraldAI;

When using the EmeraldAPI script, you can access all of an AI’s internal functions that allow you to control a wide variety of functionality. This is done through categorized classes.

It is recommended that the EmeraldSystem script is cached.

EmeraldComponent = GetComponent<EmeraldSystem>();

For users who need a working example, please use the following script to get you started. This script will instantly kill the AI this script is assigned to after pressing the H key.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using EmeraldAI;

public class AccessEmeraldExample : MonoBehaviour
{
    EmeraldSystem EmeraldComponent;

    //Cache the EmeraldSystem component
    void Start ()
    {
        EmeraldComponent = GetComponent<EmeraldSystem>();
    }
    
    //Instantly kill the AI this script is assigned to after pressing the H key
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.H))
        {
            EmeraldAPI.Combat.KillAI(EmeraldComponent);
        }
    }
}

Here's the available sections of API through the EmeraldAPI class.

Table of Contents

Last updated