Utility AI | Behaviour Tree with Utility support | State Tree with Utility support | Node Query System
This repository contains the binaries and example project for the Utility AI GDExtension for Godot Engine.
The extension contains
Together these nodes can be used to create versatile AI to your games.
If you don't know what Utility AI is, here is what Wikipedia says about it:
"...Utility AI, is a simple but effective way to model behaviours for non-player characters. Using numbers, formulas and scores to rate the relative benefit of possible actions, one can assign utilities to each action. A behaviour can then be selected based on which one scores the highest 'utility'... - Wikipedia - Utility system
If you want the source code, you can find it here: Utility AI Source Code repository.
Works on Godot 4.1.2 or newer versions. Currently 64 bit Windows, 64 bit Linux versions are available.
There are also experimental builds available for wasm32/web and MacOS (unsigned).
Just copy the addons-folder with all its contents to your Godot project root folder.
You can find the documentation here.
Read the getting started tutorials here.
JarkkoPar with Contributors. Big thank you to all of you who've helped out!
The example project contains example scenes that show how to use the various nodes. With these examples you get to know the nodes of the Utility AI GDExtension:
Agent behaviour nodes
There are also specialized sensor nodes for adding vision to the AI agents, handling ranges, booleans, for instance.
Utility enabled Behaviour Tree nodes
The UtilityAI Behaviour Tree nodes can be used independelty as a regular behaviour tree. However, they have been designed to work with Utility based Considerations and the Node Query System, which allows for more complex behaviour for your AI agents. The available nodes are:
Utility enabled State Tree nodes
The UtilityAI State Tree nodes can be used independently as a regular state tree. However, similarly to the Behaviour Tree nodes, they have been designed to work with Utility based Considerations. The available nodes are:
Node Query System nodes
The UtilityAI Node Query System is used to perform utility based queries to find Top N nodes that fit the set criteria. It as two types of nodes: Search Spaces and Search Criteria. A NodeQuerySystem-singleton can be used to set a per physics frame time budget for all the queries and to control the CPU-time of all the queries.
A Search Space defines a set of nodes you will use in your query:
A Search Criterion filters and scores the nodes in a search space to find the top N nodes:
The first example is a simple one, where one AI controlled entity follows the mouse cursor. When it gets close enough to the cursor, it stops and waits. It is a gentle introduction to Utility AI.
Example 1 |
---|
The second example provides a more elaborate example with several behaviours and behaviour groups for the AI agent with a multitude of sensors. In this example a blue and a red team of dudes pick up weapons and battle it out until only one team remains standing.
Example 2 |
---|
The third example shows a better, more re-usable way of using actions. In the earlier two examples the actions have been used only as an ID for an action. In this example the actions are extended with a script to contain the methods start_action(), execute_action() and end_action(). As a result the action node itself can be used perform what ever an action does, which both simplifies the AI Entity code and makes each action easier to share between different AI entities. | Example 3 |
---|---|
The fourth example shows how to add vision and hearing sensors to an AI agent, this time a Baddie. It uses a specialized sensor, UtilityAIArea2DVisibilitySensor, to achieve this. In the example a Baddie will chase you, the player, and investigate if you make too much noise. | Example 4 |
---|---|
The fifth example is a 2D example that shows how to use the Utility enabled Behaviour Trees together with the Node Query System. | Example 5 |
---|---|
The sixth example is a 3D example that shows how to use the Node Query System to find a cover point to hide from the player. It uses the NodeQuerySystem-singleton to manage time budget of the queries and an Area3D Search Space with a set of criteria to find the best places for the AI to hide from you. Utility AI Agent behaviours are used to select the main behaviour and one of these behaviours uses a Behaviour Tree to handle the how the behaviour is realized and how errors are handled. | Example 6 |
---|---|