Autoload

2025/12/27

Type
Learning Resource
Format
Glossary Article
Version
General
Subject Tags
Code
Assets
All else
Copyright 2016-2026, GDQuest
Created
2026/02/16
Updated
2025/12/27

Autoload

An autoload (short for auto-loaded node) is a node or scene that Godot automatically instantiates and adds as a direct child of the root node when your game starts. Autoloads are accessible from anywhere in your codebase without needing to load them beforehand.

Think of autoloads as global objects that hold data or methods you need throughout your game. They're perfect for things like creating a database of items, managing audio that should keep playing between maps like looping music, or input systems that many different parts of your game need to access.

For example, you might create an ItemDatabase autoload to manage a collection of items throughout your game. In this example, each item has a unique ID (like "potion_red") mapped to its properties:

extends Node

var _items = {
	"potion_red": {
		"display_name": "Red Potion",
		"type": "consumable",
		"heal_amount": 50,
		"price": 25,
		"icon": preload("icons/health_potion.png")
	},
	"shield_wooden": {
		"display_name": "Wooden Shield",
		"type": "armor",
		"defense": 5,
		"price": 40,
		"icon": preload("icons/wooden_shield.png")
	}
}


func get_item(item_id: String) -> Dictionary:
	return _items.get(item_id, null)


func get_random_item() -> Dictionary:
	var random_item_id: String = _items.keys().pick_random()
	return get_item(random_item_id)

Once registered as an autoload in the Project Settings, you can access it from any script. This is an example of a chest that gives the player a random item when opened:

func _on_chest_opened() -> void:
	var item: Dictionary = ItemDB.get_random_item()
	add_item_to_inventory(item)
Autoloads are not exactly singletons

While Autoloads are commonly called "singletons" in the Godot community, they're not exactly the same as the traditional Singleton design pattern.

A singleton restricts the instantiation of a class to a single object, but autoloads are normal nodes with global access, not classes that restrict instantiation to a single object. Often, we use them for the same purpose as singletons in Godot, which is why people call them "Godot's singletons."

Become an Indie Gamedev with GDQuest!

Don't stop here. Step-by-step tutorials are fun but they only take you so far.

Try one of our proven study programs to become an independent Gamedev truly capable of realizing the games you’ve always wanted to make.

Nathan

Founder and teacher at GDQuest
  • Starter Kit
  • Learn Gamedev from Zero
Check out GDSchool

You're welcome in our little community

Get help from peers and pros on GDQuest's Discord server!

20,000 membersJoin Server

Contribute to GDQuest's Free Library

There are multiple ways you can join our effort to create free and open source gamedev resources that are accessible to everyone!