GDScript Fundamentals

Lesson 1 of 7

Introduction to GDScript & Godot

Godot is a free, open-source game engine, and GDScript is its built-in scripting language, designed specifically to feel natural for game development and to integrate tightly with the engine's editor.

Nodes and the scene tree

Everything in a Godot game is a node: a sprite, a button, a sound player, even an abstract logic container. Nodes are arranged into a tree, and a saved tree of nodes is called a scene:

Player (CharacterBody2D)
├── Sprite2D
├── CollisionShape2D
└── Camera2D

A scene can be instanced inside another scene, exactly like a reusable component, this is how a "Player" scene gets placed into a "Level" scene without duplicating its logic.

Your first script

extends Node2D

func _ready():
    print("Hello, Kodstigen!")

func _process(delta):
    # runs every single frame, delta is the time since the last frame in seconds
    pass
  • extends Node2D attaches this script's behavior to a node of type Node2D (or anything that inherits from it), scripts in Godot are never standalone, they always extend some node type.
  • _ready() is a lifecycle method the engine calls automatically once, when the node first enters the running scene.
  • _process(delta) is called automatically every rendered frame, delta lets you write movement and animation that's consistent regardless of frame rate.

TIP

Function names starting with an underscore, like _ready and _process, are engine callbacks, Godot calls them for you at the right moment, you never call them yourself directly.

📝 Introduction to GDScript Quiz

Passing score: 70%
  1. 1.What is a "scene" in Godot?

  2. 2._process(delta) is called automatically by the engine every frame.

  3. 3.The lifecycle method Godot calls automatically once, when a node first enters the running scene, is: _____()