Inheritance

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

Inheritance

Inheritance is a process through which a class gets access to all the member functions and variables of another class. We say that it "extends" it.

In Godot, with the GDScript programming language, we can make a script extend another script or a class built into Godot using the extends keyword.

We describe the relationship between the script and the class it extends as a parent-child relationship. The parent class is the one extended by the child. The child class inherits from the parent.

For example, when you begin a script with the line extends Area2D, the parent class is Area2D, and the child class is the script.

With inheritance and this extends keyword, the child script literally extends and gets access to all the code provided by the parent class, Area2D, in this example. It's as if the script contained all the code of Area2D plus everything in the script.

There is a long chain of inheritance in the Godot game engine. For example, the Area2D node extends CollisionObject2D, which extends Node2D, which extends CanvasItem, which extends Node, which extends RefCounted, which finally extends Object.

So, the Area2D node has access to all the functions and properties of Node2D, CanvasItem, Node, RefCounted, and Object. You can see a fair part of it in the Inspector dock: the sections tell you which classes each property comes from.

Inheritance chain in the Inspector

The inheritance chain is why all the nodes in Godot have access to the add_child() and get_node() functions, among others. These two functions are part of the Node class in the engine, and every node type inherits from it.

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!