Godot Limbo AI Conditions

This article is all about Godot and LimboAI Behavior Tree Conditions. In previous articles I went over the basics of behavior trees and how to create a simple game with them.
If you haven't read the previous article you can check it out here:
You can check out the game here:
Behavior Tree Conditions
Conditions are a type of node that can be used to check the state of the game or the AI. They are used to determine if an action should be taken.
extends BTCondition
@export var target_var := &"target"
func _tick(delta: float) -> Status:
var target: CharacterBody2D = blackboard.get_var(target_var, null)
if target == null:
return FAILURE
return SUCCESS
- First it extends from
BTCondition
as opposed toBTAction
like a normal task would. - Then it exports a variable
target_var
which is the key in the blackboard that the condition will check. - If it has a target on the blackboard it will return
SUCCESS
otherwise it will returnFAILURE
. - It makes it easy to check if you have a target or not in your sequences.
Conditions typically don’t take multiple ticks to finish and return either SUCCESS or FAILURE immediately.
So in my case I have two sequences, a Wander sequence and an Attack sequence.
- The Wander sequence will only run if there is no target.
- The Attack sequence will only run if there is a target.
Conclusion
Conditions are a great way to check the state of the game or the AI. They are used to determine if an action should be taken.