TExcelTAD
Home › Godot 4 with GDScript › AssetLib & Addons: Dialogic, Phantom Camera, LimboAI

AssetLib & Addons: Dialogic, Phantom Camera, LimboAI

Godot's core is deliberately small, and the community fills the gaps with addons: editor plugins, new node types and tools. This lesson shows how addons are installed and structured, then four that come up again and again in Godot projects: Dialogic for dialogue, Phantom Camera for cameras, LimboAI for behaviour trees and state machines, and Aseprite importers for pixel-art animation. Testing addons (GUT, gdUnit4) have their own lesson: Testing with GUT & gdUnit4.

Note: Addons are community projects with their own release cycles. Check each one's page for the Godot versions it supports before you upgrade your editor, and pin the addon version in your repository.

Installing from the AssetLib

  1. Click AssetLib at the top of the editor (next to 2D, 3D and Script).
  2. Search, open the asset, and click Download, then Install. Godot shows the files it will add; addons normally go into res://addons/<name>/.
  3. If the asset is an editor plugin, enable it in Project > Project Settings > Plugins.

The same assets are browsable at godotengine.org/asset-library. You can also install from GitHub releases by copying the addons/<name>/ folder into your project; that's the usual way to get a version newer than the AssetLib copy. A new Asset Store for Godot is being developed by the Godot Foundation as well; check its current state.

Commit addons/ to version control. The addon is part of your project, and teammates and CI need the exact same version.

What an addon looks like

An editor plugin is a folder with a plugin.cfg and a script that extends EditorPlugin:

text
res://addons/my_tool/
├── plugin.cfg
├── plugin.gd
└── my_node.gd
ini
[plugin]
name="My Tool"
description="Adds a MyNode type."
author="You"
version="1.0"
script="plugin.gd"
gdscript
@tool
extends EditorPlugin

func _enter_tree() -> void:
	add_custom_type("MyNode", "Node2D", preload("my_node.gd"), preload("icon.svg"))

func _exit_tree() -> void:
	remove_custom_type("MyNode")

Many addons don't need a plugin at all: a script with class_name already appears in the Create New Node dialog. Addons that add native code ship a GDExtension library instead (see GDExtension (C++) Overview).

Dialogic 2: dialogue and visual-novel tools

Dialogic adds a dialogue editor to Godot: characters (names, portraits, colours), timelines (the conversation as a list of events: text, choices, conditions, signals, variable changes, portraits joining and leaving) and customisable text boxes. Timelines can be edited visually or as text:

text
join Juliet left
Juliet: Who goes there?
- Friend
	Juliet: Then come closer.
- Nobody
	Juliet: Nobody talks quite loudly.
[signal arg="quest_started"]

Starting a timeline from code and reacting to it:

gdscript
func _on_npc_interacted() -> void:
	Dialogic.signal_event.connect(_on_dialogic_signal)
	Dialogic.timeline_ended.connect(_on_dialogue_done, CONNECT_ONE_SHOT)
	Dialogic.start("juliet_intro")

func _on_dialogic_signal(argument: String) -> void:
	if argument == "quest_started":
		quests.start("balcony")

func _on_dialogue_done() -> void:
	player.set_physics_process(true)

Dialogic 2 targets Godot 4 (its docs list the minimum 4.x version) and is still marked alpha: it is widely used, but expect breaking changes between versions and read the changelog before updating. For lighter needs, Dialogue Manager (by Nathan Hoad) is a popular script-like alternative.

Phantom Camera: camera rigs without code

Phantom Camera brings Cinemachine-style cameras to Godot (Unity users: compare Cinemachine Cameras). You place several PhantomCamera2D or PhantomCamera3D nodes in the scene, each describing a camera setup: what to follow, how, with what limits. A PhantomCameraHost node, a child of your real Camera2D/Camera3D, moves the camera to whichever phantom camera has the highest priority, with a tween between them.

text
Level (Node2D)
├── Camera2D
│   └── PhantomCameraHost
├── Player (CharacterBody2D)
├── PCamFollow (PhantomCamera2D)     follow mode: Framed, target: Player, priority 10
└── PCamBossRoom (PhantomCamera2D)   follow mode: None, positioned over the arena, priority 0

Follow modes include Glued, Simple, Group (keep several targets in frame), Path and Framed (a dead zone), plus Third Person in 3D, and 3D look-at modes. Switching to the boss camera when the player enters the arena is one line, typically in an Area2D signal handler:

gdscript
func _on_boss_room_body_entered(body: Node2D) -> void:
	if body.is_in_group("player"):
		$PCamBossRoom.priority = 20     # the host tweens to the highest priority

The win over a hand-written camera script is design time: priorities, dead zones, damping and transitions are all inspector values with a live preview. See Camera2D for what the engine does by itself.

LimboAI: behaviour trees and state machines

LimboAI adds behaviour trees (with a visual editor and a debugger that shows the running tree) and hierarchical state machines. It is available as a C++ module (a custom Godot build with all features) or as a GDExtension from the AssetLib (no custom build, slightly fewer features); each LimboAI release lists which Godot versions it supports.

A custom behaviour-tree task is a GDScript class with a _tick() that returns SUCCESS, FAILURE or RUNNING:

gdscript
@tool
extends BTCondition

@export var max_distance := 64.0
@export var target_var: StringName = &"target"

func _generate_name() -> String:
	return "InRange %.0f px  of %s" % [max_distance, LimboUtility.decorate_var(target_var)]

func _tick(_delta: float) -> Status:
	var target: Node2D = blackboard.get_var(target_var, null)
	if not is_instance_valid(target):
		return FAILURE
	return SUCCESS if agent.global_position.distance_to(target.global_position) <= max_distance else FAILURE

The state machine side is set up in code:

gdscript
@onready var hsm: LimboHSM = $LimboHSM
@onready var idle: LimboState = $LimboHSM/IdleState
@onready var chase: LimboState = $LimboHSM/ChaseState

func _ready() -> void:
	hsm.add_transition(idle, chase, &"player_seen")
	hsm.add_transition(chase, idle, chase.EVENT_FINISHED)
	hsm.initial_state = idle
	hsm.initialize(self)
	hsm.set_active(true)

func _on_vision_body_entered(_body: Node2D) -> void:
	hsm.dispatch(&"player_seen")

How does a behaviour tree decide? Here is a runnable GDScript model of the core idea with the same three statuses: a Selector tries children until one doesn't fail, a Sequence runs children until one doesn't succeed, and an action that needs more time returns RUNNING and is ticked again next frame:

gdscript · try it yourself
extends SceneTree

# A tiny behaviour tree, modelled on the task API of LimboAI (SUCCESS / FAILURE / RUNNING).
enum Status { SUCCESS, FAILURE, RUNNING }

class Task:
	func tick(_bb: Dictionary) -> Status:
		return Status.SUCCESS

class Sequence extends Task:      # runs children in order; stops at the first one that doesn't succeed
	var children: Array[Task]
	func _init(c: Array[Task]): children = c
	func tick(bb: Dictionary) -> Status:
		for c in children:
			var s := c.tick(bb)
			if s != Status.SUCCESS:
				return s
		return Status.SUCCESS

class Selector extends Task:      # tries children in order; stops at the first one that doesn't fail
	var children: Array[Task]
	func _init(c: Array[Task]): children = c
	func tick(bb: Dictionary) -> Status:
		for c in children:
			var s := c.tick(bb)
			if s != Status.FAILURE:
				return s
		return Status.FAILURE

class InRange extends Task:       # a condition
	var max_distance: float
	func _init(d: float): max_distance = d
	func tick(bb: Dictionary) -> Status:
		return Status.SUCCESS if absf(bb.target_x - bb.x) <= max_distance else Status.FAILURE

class Attack extends Task:
	func tick(bb: Dictionary) -> Status:
		bb.log = "attack!"
		return Status.SUCCESS

class MoveToTarget extends Task:  # an action that takes several ticks
	func tick(bb: Dictionary) -> Status:
		bb.x += signf(bb.target_x - bb.x) * minf(4.0, absf(bb.target_x - bb.x))
		bb.log = "move to %.0f" % bb.x
		return Status.SUCCESS if bb.x == bb.target_x else Status.RUNNING

func _init():
	var tree := Selector.new([
		Sequence.new([InRange.new(2.0), Attack.new()]),
		MoveToTarget.new(),
	])
	var bb := {"x": 0.0, "target_x": 10.0, "log": ""}
	for t in 5:
		var s: Status = tree.tick(bb)
		print("tick ", t + 1, ": ", bb.log, " -> ", Status.keys()[s])
	quit()
tick 1: move to 4 -> RUNNING
tick 2: move to 8 -> RUNNING
tick 3: attack! -> SUCCESS
tick 4: attack! -> SUCCESS
tick 5: attack! -> SUCCESS

The bb dictionary plays the role of LimboAI's blackboard: shared data that tasks read and write. LimboAI adds what the model lacks: decorators, parallel nodes, an editor, per-task _enter/_exit, and a debugger. The theory is in the Game AI course. For simple enemies, a hand-written state machine is often enough: A State Machine in GDScript.

Aseprite importers

Pixel artists animate in Aseprite with tags (idle, run, jump). Importer addons turn a .aseprite file straight into Godot resources, so you never export sprite sheets by hand:

  • Aseprite Wizard (by Vinicius Gerevini) is the best known. It can create SpriteFrames for AnimatedSprite2D, or animation tracks for an AnimationPlayer driving a Sprite2D, one animation per tag, and re-imports when the file changes.
  • Other importers on the AssetLib take a similar approach with different node setups; pick one whose output matches how you animate (see AnimationPlayer & AnimatedSprite2D).

These importers call the Aseprite command-line tool, so Aseprite must be installed and its path set in the addon's settings on every machine that imports, including CI. Teams often commit the generated resources too, so artists' machines aren't required to build the game.

More addons worth knowing

Addon What it does
GUT, gdUnit4 unit and scene tests (lesson)
Dialogue Manager script-style branching dialogue
Beehave another behaviour-tree addon, pure GDScript
SmartShape2D terrain from 2D paths with textured edges
Terrain3D, HTerrain large 3D heightmap terrains
GodotSteam Steamworks API (achievements, lobbies, overlay)
Debug draw addons draw lines, boxes and text in 3D from code for debugging

Before adding an addon, check: when was it last updated, which Godot versions it supports, its licence (most are MIT), and whether you could write the 50 lines you actually need yourself. Each addon is code you now maintain.

Test yourself

Where do addons normally live in a Godot project, and how is an editor plugin activated?

  1. In .godot/, activated automatically
  2. In res://addons/<name>/, enabled in Project Settings > Plugins
  3. In the user:// folder
  4. Anywhere, enabled from the Export dialog

In Phantom Camera, how does the real camera decide which PhantomCamera to use?

  1. The first one in the scene tree
  2. The one with the highest priority, managed by the PhantomCameraHost under the Camera node
  3. Randomly each frame
  4. It must be set in project.godot

In a behaviour tree, a Selector's first child returns FAILURE and the second returns RUNNING. What does the Selector return?

  1. FAILURE
  2. SUCCESS
  3. RUNNING
  4. It runs the first child again