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 this context, we believe that you have already read the previous pages of User Scripting section.
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

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
MonoBehaviourparent class toKey<PlatformData>
Done. It's all required steps to define your our key in AITree. Any other type can be used instead of the PlatformData type.
Now we can update MovePlatformTask class.

We can improve displaying of PlatformKey in editor. For that we will use Apex library what included in AITree out of box.
Open PlatformKey class add following attributes on field of PlatformData struct.
Now our PlatformKey looks much better.

Last updated