Decorators

Description of decorators properties.

Flow Control

Flow Control determines when the decorator checks its condition to either continue or stop executing a branch of the Behavior Tree. This includes options like On Value Change and On Result Change.

Notify observer

Notify observer - In which case should notify the observer?

Name
Description

On Value Change

This mode allows the decorator to react whenever the value of the variable it’s monitoring changes. It’s useful when the condition needs to be checked dynamically in real-time.

On Result Change

In this mode, the decorator only checks the condition when the result differs from the previous check. This means if the result changes from "true" to "false" or vice versa, only then will the decorator recheck the condition.

Examples:

  • On Value Change: An AI character is monitoring an enemy's health, and if the health changes, it may decide whether to continue attacking. If the value changes (e.g., the enemy’s health drops below a certain threshold), the Behavior Tree can make a new decision.

  • On Result Change: AI is tracking whether an enemy is within line of sight. If the enemy was visible and then disappears, this change will trigger a recheck and possibly switch the AI's behavior (e.g., from attacking to searching for the enemy).


Observer Abort

Observer abort - determine how and when the Behavior Tree can be interrupted if the decorator's condition changes. A decorator can abort the execution of the current branch or neighboring tasks.

Name
Description

None

Observation does not abort tasks.

Self

If the condition of the decorator changes (e.g., becomes false), the current branch of the tree is stopped, and the AI switches to another branch.

Low Priority

Tasks with lower priority (below in the tree) are aborted if the decorator's condition becomes false.

Both

Both the current branch and lower priority tasks are aborted.

Examples

  • None: The AI continues its current action, even if the condition monitored by the decorator has changed.

  • Self: If the AI is chasing an enemy, but the enemy goes out of sight, the condition becomes false, and the chase branch is aborted. The AI may switch to another action, like returning to patrol.

  • Low Priority: The AI is chasing an enemy, but a higher-priority condition occurs (e.g., detecting a more dangerous enemy). The chase behavior is interrupted, and the AI switches to deal with the new threat.

  • Both: The AI might be simultaneously engaged in chasing and monitoring for safety (e.g., watching for enemies behind). If one condition changes (e.g., the AI gets attacked from behind), both the current and lower-priority branches will be interrupted to switch the AI’s focus to defending itself.


Comparers

Comparers define how a decorator compares a variable’s value to a target value. This is similar to regular comparison operators, such as "equal", "greater than", "less than", etc. In Behavior Trees, this allows the AI to make decisions based on complex conditions.

Check box - only checks if bool value is true or false.

Example of how to select comparer for bool key is shown below.

Examples

  • Equal: If the AI should only attack an enemy if its health is equal to 100%, the decorator will use "equal to 100%".

  • Not Equal: The AI can retreat to cover if its health is not full.

  • Greater Than: The AI may decide to attack only when its health is greater than 50%.

  • Less Than: The AI might flee or seek cover if its health drops below 20%.


Decorators in AI Tree offer a flexible way to control the flow of task execution, checking conditions based on variable or result changes, and interrupting current tasks depending on how conditions change. These properties allow you to configure complex behavioral systems for AI, making them more adaptive and realistic.

Last updated