Custom Key

Instruction to create custom user key

In the AI Tree you can easily create your own task by using scripting API. In this page we will show how you can do it.

In the previous section, we created a task for the platform moving. Let's create unique key for defining point A, B and speed.

Create new script and call it PlatformKey, after creation open it script in you scripts editor tool.

Create -> MonoBehaviour Script

PlatformKey script in project window

Default Unity MonoBehaviour script template.


First of all we need to decide what we will define as key. Let's create new struct PlatformData. Don't forget to add [Serializable] attribute for custom types.


Now we are ready to define our PlatformData key. We need to change the PlatformKey class.

  • Remove all methods.

  • Change MonoBehaviour parent class to Key<PlatformData>


Now we can update MovePlatformTask class.

Platform key in Inspector window

We can improve displaying of PlatformKey in editor. For that we will use Apex library what included in AITree out of box.

All editor classes, tasks, keys, decorators, components in AI Tree powered by Apex.

Open PlatformKey class add following attributes on field of PlatformData struct.

Now our PlatformKey looks much better.

PlatformKey powered by Apex

Last updated