Game Development

Godot Tutorial for Beginners: Project Setup and Your First Game Scene

Set up a Godot project, build a player scene, wire up input, and make a playable 2D main scene. Then save, run, and fix the usual beginner issues like tiny sprites, wrong filters, and idle/run animation handling.

8 min read
Godot Engine editor showing a 2D scene with a small player character centered in the main viewport and the Inspector and FileSystem panels open.
Godot Engine displays a 2D scene with the player character visible in the main viewport. — footage: Coding With Russ

Start by creating a player scene using CharacterBody2D, organize your files for images, scenes, and scripts, and import your sprite sheet. Instancing the player scene in a main scene keeps playtest flexible. Set up animations with AnimatedSprite2D, define custom inputs, attach and adjust your player script, and use Project Settings to sharpen pixel art. Save your scenes, run the project, and handle movement, scale, and animation issues as they appear.

Project setup

prerequisites

  • Godot Engine installed and running (2D mode preferred for this project).
  • FileSystem panel is your workspace. Create dedicated folders: one each for images, scenes, and scripts.
  • Import your player sprite sheet by dragging it into the images/player folder so Godot brings it into the project.
  • Assets are locally available before creating nodes and scenes.

Scene system

Begin by creating the player as a reusable scene, then set up the main game scene where everything is assembled.

  1. Create the player scene:
    • In the node panel, search for CharacterBody2D and add it as the root node.
    • Rename this node to player for clarity.
    • Save this scene to your scenes folder.

Godot editor with the Scene tree on the left showing a node named Player selected, and the Inspector on the right displaying CharacterBody2D properties.

The Godot editor shows a scene tree with Player selected and CharacterBody2D properties in the Inspector. — Coding With Russ

  1. Set up the main scene:

    • Create a new 2D scene (the simplest 2D node available).
    • Rename this root node to main.
    • Save this as your main game scene inside the scenes folder.
  2. Instance the player into the main scene:

    • With your main scene open, use Instantiate Child Scene and select your player scene. This allows you to position the player and later add enemies or terrain.
    • Move the player node to your desired location in the main scene, not in the player scene itself.

Nodes and sprite frames

Set up sprite animation using AnimatedSprite2D and organize your animations:

  1. Add AnimatedSprite2D as a child of the player node.
  2. In the Inspector, create new SpriteFrames and open the animation panel at the bottom of the editor.
  3. Use Add Frames from Sprite Sheet to import and split your sprite sheet:
    • Adjust the columns and rows until every frame is in its own box. For example, you may need to set columns to 6 and rows to 10 if that's what your asset uses.
    • Drag to select the frames for each animation (such as idle_right, idle_up).
  4. Rename each animation clearly, like idle_right, idle_up, so your script can reference them.
  5. Enable looping for repeating animations such as idle.
  6. Adjust the frame rate in the animation panel to make the animation feel natural (for example, running faster than idle).

Godot editor with an AnimatedSprite2D node selected and the SpriteFrames editor open at the bottom.

The Godot Inspector shows an AnimatedSprite2D with SpriteFrames selected while the animation frames panel is open below. — Coding With Russ

Editor workflow

Godot editor with the Project Settings window open to Rendering > Textures, showing Canvas Textures and the Default Texture Filter set to Linear.

The Project Settings window is open on Rendering > Textures, with the Default Texture Filter setting visible as Linear. — Coding With Russ

Script basics

Attach your first script to the player node, clean up platformer code, and set up movement and animation functions:

  1. Attach a GDScript file to the player node and save it in your scripts folder for project organization.
  2. The generated script includes platformer logic: gravity and jumping. Remove those sections for a top-down (non-jumping) game.
  3. Define your custom input actions in the project settings’ Input Map for left, right, up, down, attack, and map both arrow keys and WASD as needed. Don’t use the out-of-the-box UI left/right actions for gameplay.
  4. Refactor the movement code:
    • Add your own process_movement function and call it from _physics_process.
    • Use get_vector to read input for all four directions.
    • Multiply the direction by speed and assign it to the velocity.
  5. Split animation handling:
    • Add a play_animation function that selects the correct animation based on direction and state.
    • Add a process_animation function to pick between idle, run, or attack based on movement.

Here’s a basic template drawn from the process:

# scripts/player.gd
extends CharacterBody2D

const SPEED = 200.0

var last_direction = Vector2.RIGHT

@onready var animated_sprite_2d = $AnimatedSprite2D

func _physics_process(_delta):
    process_movement()
    process_animation()

# Handles movement and updates last_direction
func process_movement():
    var direction = Input.get_vector("left", "right", "up", "down")
    if direction != Vector2.ZERO:
        velocity = direction * SPEED
        last_direction = direction
    else:
        velocity = Vector2.ZERO
    move_and_slide()

# Decides which animation to play
func process_animation():
    if velocity != Vector2.ZERO:
        play_animation("run", last_direction)
    else:
        play_animation("idle", last_direction)

# Select and play the animation; flips left/right as needed
func play_animation(prefix, direction):
    if direction.x != 0:
        animated_sprite_2d.animation = "%s_right" % prefix
        animated_sprite_2d.flip_h = direction.x < 0
    elif direction.y < 0:
        animated_sprite_2d.animation = "%s_up" % prefix
        animated_sprite_2d.flip_h = false
    elif direction.y > 0:
        animated_sprite_2d.animation = "%s_down" % prefix
        animated_sprite_2d.flip_h = false
    animated_sprite_2d.play()
  • When you see a yellow warning about an unused delta parameter, rename it to _delta in your _physics_process to clear the warning.

Playtest and fix movement

Test your playable scene and fix common movement/animation problems as they come up.

Godot Engine is open with a running game window centered on the editor, showing a small player sprite in a gray main scene.

Godot Engine displays a running game window with the player visible in the main scene. — Coding With Russ

before after

Before

Before
Player movement switches to the default idle animation without regard to the last movement direction. When the player stops moving, the facing direction resets and idle animation always shows a default facing.

After
A last_direction variable stores the most recent movement direction. When stationary, the idle animation is played in the direction the player was last moving. Animation state and facing now match expected behavior.

After

To test:

  • Run the project from the main scene. The player should appear in the window at the correct scale and position.
  • Move the player with arrow keys or WASD. The run animations update in each direction, including diagonals.
  • When the player stops, the idle animation matches the last direction moved.
  • If you see any warnings about unused parameters in scripts, prefix the variable with an underscore and re-save.

Also worth knowing

  • Project-wide texture filter: Set the texture filter to nearest in Project Settings once, so all pixel art appears crisp and you do not have to adjust each sprite.
  • Custom input actions: Define input actions like left, right, up, down, and attack in the Input Map for predictable gameplay behavior, instead of using default UI actions.
  • Persistent facing: Use a last direction variable, so when movement stops the player keeps facing the correct way in idle.
  • Strip platformer code: CharacterBody2D scripts come with gravity and jump handling; remove these for a top-down game to prevent unwanted behaviors.
  • Unused parameter warning: If you see a warning about an unused parameter like delta, prefix it with an underscore (e.g., _delta) to silence the warning.

FAQ

how to start a Godot project

Start by making a player scene using CharacterBody2D, import your art and assets into organized folders, and save your player scene before building a main scene that instances it.

Godot first 2D game tutorial

Create a player using CharacterBody2D and AnimatedSprite2D, set up input actions, attach a movement script, and build a main scene that instantiates your player node for testing.

Godot scene and node basics

Every game object is a node. Bundle nodes together into scenes to create reusable entities like a player or an enemy, and combine them in a main scene to assemble your level.

Godot beginner setup guide

Organize by creating folders for images, scenes, and scripts. Import your assets, set up your game structure with scenes for player and main, and adjust Project Settings for your art and input actions.

how to make a playable scene in Godot

Save your scenes, instantiate the player in your main scene, configure input in the Input Map, and run the project from the main scene with scripts attached for movement and animation.

Godot install and first run

After installing Godot, launch the editor, switch to the 2D workspace, create your first scene, and test it in the game window. Use the run buttons to preview both individual scenes and the whole project.


Official reference: Godot documentation.

Sources

Screenshots on this page are frames from the videos below, used to illustrate the steps they describe. All rights remain with their creators.

Checked against: