Unity Node-Based AI Editor

Created
Jan 23, 2024 11:29 AM
Skills
Data-driven Development
Editor Programming
AI Behaviour Trees
Technologies
C#
Unity
.NET
notion image

My Responsibilities

  • Build a node-graph editor in Unity 2021.
  • Create a Unity editor plugin to facilitate ease of use in the development pipeline.
  • Add JSON / ScriptableObject file save and load system with export for stripping out editor elements to provide a more optimised file for use in AI controllers.
  • Create a process to build AI nodes that can reliably control a non-player character.

The Story

For a personal game project that unfortunately never came to fruition, I wanted a more advanced AI system that could be added to and edited a lot more easily than messing with files or ScriptableObjects in the inspector, so I decided to create a node-graph editor for this purpose.
 
Starting with reading the documentation around the node graph editor I soon had a basic node graph set up in Unity 2021 and I built out the types of node I could use for controlling the AI characters.
 
When it came to displaying nodes on the graph I had some issues with the display of the nodes. I wanted adjustable data or variable inputs to be displayed under the flow input and outputs and initially it looked messy. Once I added some proper padding, fixed the box expansion code and wrote some auto-layout code, I got it working the way I wanted it to.
 
After this I created a variable system with a UI box that allowed for variables to be dragged into the graph and connected with any nodes, these variables would be fed in from outside of the AI controller, such as GameObject references or adjustable data like a speed or detection range.
 
Built with Potion.so