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.
Launch Godot and Create a Project
- Open the Godot Engine application
- In the Project Manager, click New Project
- Choose a project name (e.g., “MyFirstGame”)
- Select a folder location for your project
- Choose Forward+ as the renderer (best for 3D) or Mobile for 2D games
- Click Create & Edit
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.
Create Your First Scene
Let’s create a simple 2D scene:
- In the Scene panel, click 2D Scene (or click the + icon and add a Node2D)
- Your scene now has a root Node2D
- Save the scene: Press
Ctrl+S(orCmd+Son macOS) - Name it
Main.tscn
Add a Sprite2D Node
Let’s add a visual element:
- With the Node2D selected, click the + button at the top of the Scene panel
- Search for Sprite2D and select it
- Click Create
- You now have a Sprite2D as a child of Node2D
- Select the Sprite2D node
- In the Inspector, find the Texture property
- Click [empty] and choose Load
- Navigate to
icon.svgin your project folder
Attach a GDScript
Now let’s make our sprite interactive with code:
- Select the Node2D (root node)
- Click the Attach Script button (scroll/paper icon) at the top of the Scene panel
- Leave the default settings and click Create
Write Your First Script
Replace the default script content with this code: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;deltais time since last frameInput.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.Run Your Scene
Time to test your game!
- Press F5 (or click the Play button in the top-right)
- If prompted to select a main scene, click Select Current
- A game window opens showing your spinning sprite
- Use the arrow keys to move it around
- Press F8 or close the window to stop
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:Learn More About Nodes
Explore different node types for 2D, 3D, UI, and more in the Nodes and Scenes documentation.
Master GDScript
Deep dive into GDScript syntax, types, and patterns in the Scripting Guide.
Build a Complete Game
Follow a full tutorial to create a complete 2D or 3D game from start to finish.
Explore the API
Browse the API Reference to discover all available classes and methods.
Common Patterns
Getting Node References
Getting Node References
There are several ways to reference other nodes in your scene:
Understanding Delta Time
Understanding Delta Time
The
delta parameter in _process() and _physics_process() represents the time elapsed since the last frame in seconds:Signals for Communication
Signals for Communication
Signals are Godot’s way of implementing the observer pattern. They let nodes communicate without tight coupling:
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.