Skip to main content

Create Your First Godot Game

This guide will walk you through creating a simple 2D game project to get familiar with Godot’s workflow.
Before starting, make sure you have Godot installed. See the Installation Guide if you haven’t installed it yet.
1

Launch Godot and Create a Project

  1. Open the Godot Engine application
  2. In the Project Manager, click New Project
  3. Choose a project name (e.g., “MyFirstGame”)
  4. Select a folder location for your project
  5. Choose Forward+ as the renderer (best for 3D) or Mobile for 2D games
  6. Click Create & Edit
The project manager keeps track of all your Godot projects, making it easy to switch between them.
2

Understand the Editor Interface

When the editor opens, you’ll see several key panels:
  • Viewport (center): Where you design your scenes visually
  • Scene Tree (left): Shows the hierarchy of nodes in your current scene
  • Inspector (right): Displays properties of the selected node
  • FileSystem (bottom-left): Browse your project files
  • Bottom Panel: Output, debugger, animation tools, etc.
Godot uses a scene system where everything is a tree of nodes. Each node has a specific purpose and can be customized in the Inspector.
3

Create Your First Scene

Let’s create a simple 2D scene:
  1. In the Scene panel, click 2D Scene (or click the + icon and add a Node2D)
  2. Your scene now has a root Node2D
  3. Save the scene: Press Ctrl+S (or Cmd+S on macOS)
  4. Name it Main.tscn
Always save your scenes! Godot won’t auto-save unsaved scenes.
4

Add a Sprite2D Node

Let’s add a visual element:
  1. With the Node2D selected, click the + button at the top of the Scene panel
  2. Search for Sprite2D and select it
  3. Click Create
  4. You now have a Sprite2D as a child of Node2D
For now, the sprite won’t show anything because it doesn’t have a texture. You can add one from the Inspector panel or use the Godot icon:
  1. Select the Sprite2D node
  2. In the Inspector, find the Texture property
  3. Click [empty] and choose Load
  4. Navigate to icon.svg in your project folder
You should now see the Godot logo in the viewport!
5

Attach a GDScript

Now let’s make our sprite interactive with code:
  1. Select the Node2D (root node)
  2. Click the Attach Script button (scroll/paper icon) at the top of the Scene panel
  3. Leave the default settings and click Create
This creates a new GDScript file and opens it in the script editor.
GDScript files use the .gd extension and are saved in your project folder.
6

Write Your First Script

Replace the default script content with this code:
extends Node2D

# Reference to our sprite
@onready var sprite = $Sprite2D

# Rotation speed in radians per second
var rotation_speed = 2.0

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
    print("Game started!")
    print("Use arrow keys to move the sprite")

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
    # Rotate the sprite
    sprite.rotation += rotation_speed * delta
    
    # Move sprite with arrow keys
    var velocity = Vector2.ZERO
    
    if Input.is_action_pressed("ui_right"):
        velocity.x += 1
    if Input.is_action_pressed("ui_left"):
        velocity.x -= 1
    if Input.is_action_pressed("ui_down"):
        velocity.y += 1
    if Input.is_action_pressed("ui_up"):
        velocity.y -= 1
    
    # Normalize to prevent faster diagonal movement
    if velocity.length() > 0:
        velocity = velocity.normalized()
    
    # Move the sprite
    sprite.position += velocity * 200 * delta
Understanding the code:
  • extends Node2D: This script extends the Node2D class
  • @onready var sprite = $Sprite2D: Gets a reference to the Sprite2D child node
  • _ready(): Called once when the node enters the scene tree
  • _process(delta): Called every frame; delta is time since last frame
  • Input.is_action_pressed(): Checks if a key is being pressed
  • We rotate the sprite continuously and move it based on arrow key input
The @onready annotation ensures the variable is initialized when the node is ready, after all children are available.
7

Run Your Scene

Time to test your game!
  1. Press F5 (or click the Play button in the top-right)
  2. If prompted to select a main scene, click Select Current
  3. A game window opens showing your spinning sprite
  4. Use the arrow keys to move it around
  5. Press F8 or close the window to stop
Press F6 to run the currently edited scene without setting it as the main scene.
Congratulations! You’ve created your first interactive Godot scene.

What You’ve Learned

Scene System

How to create scenes with a hierarchy of nodes.

Node Types

Used Node2D and Sprite2D for 2D game objects.

GDScript Basics

Wrote your first script with _ready() and _process() functions.

Input Handling

Detected keyboard input to control game objects.

Next Steps

Now that you’ve created your first Godot project, explore these topics:
1

Learn More About Nodes

Explore different node types for 2D, 3D, UI, and more in the Nodes and Scenes documentation.
2

Master GDScript

Deep dive into GDScript syntax, types, and patterns in the Scripting Guide.
3

Build a Complete Game

Follow a full tutorial to create a complete 2D or 3D game from start to finish.
4

Explore the API

Browse the API Reference to discover all available classes and methods.

Common Patterns

There are several ways to reference other nodes in your scene:
# Using @onready with $ shorthand (recommended)
@onready var player = $Player
@onready var child = $"Child Node"  # For nodes with spaces

# Using get_node() - equivalent to $
@onready var player = get_node("Player")
@onready var player = get_node(^"Player")  # StringName for better performance

# Getting nodes at runtime
func _ready():
    var sprite = get_node("Sprite2D")
    var parent = get_parent()
    var tree = get_tree()
The delta parameter in _process() and _physics_process() represents the time elapsed since the last frame in seconds:
func _process(delta: float) -> void:
    # delta is typically ~0.016 at 60 FPS
    # Multiply by delta to make movement frame-rate independent
    position.x += 100 * delta  # Moves 100 pixels per second
    rotation += PI * delta      # Rotates 180° per second
Always multiply movement and time-based changes by delta to ensure consistent behavior regardless of frame rate.
Signals are Godot’s way of implementing the observer pattern. They let nodes communicate without tight coupling:
# Define a signal
signal health_changed(new_health)
signal died

func take_damage(amount):
    health -= amount
    health_changed.emit(health)  # Emit signal with parameter
    
    if health <= 0:
        died.emit()  # Emit signal without parameters

Resources

Official Demos

Browse official example projects covering various features.

Community Tutorials

Explore text and video tutorials from the Godot community.

Class Reference

Access detailed documentation for every class and method.

Godot Forum

Ask questions and share your projects with the community.

Build docs developers (and LLMs) love