Make Games with Godot 4 and AI · Lesson 2 of 11

Godot 4 Nodes and Scenes: Add a Character and Coins (Lesson 2)

Every Godot game is made of scenes, and every scene is made of building blocks called nodes. In this lesson you'll put a title, a character, and coins on screen to lay the visual groundwork for the game.

Last time, we created a Node2D named Main and a Label for the title, then ran the game. This lesson picks up right where we left off. If you skipped those steps, do just the "Your first run" section of Lesson 1 first.

Nodes are building blocks

Godot games are built by combining building blocks called nodes. There are many kinds of nodes, and each one is good at one specific job.

NodeWhat it doesWhere we use it in this series
Node2DHas a 2D position, rotation, and scale. Often used as a "container" that groups other nodesHolds the whole game together (Main)
Sprite2DDisplays a single imageThe character and the coins
LabelDisplays textThe title and the score
CharacterBody2DA body that moves and collides with walls and floorsThe player in Lesson 4
Area2DDetects when something overlaps itCollecting coins in Lesson 6
Camera2DDecides which part of the world is shown on screenWhen we make the stage bigger in Lesson 5

A single node can't do much on its own, but by combining them you can make "a character that shows an image (Sprite2D), bumps into walls (CharacterBody2D), and picks up coins (Area2D)."

Scenes are groups of building blocks

When you arrange nodes into a tree and save it as a file, that's a scene. Scene files use the .tscn extension.

  • The main game screen (main.tscn) is a scene
  • A single coin (coin.tscn) is also a scene
  • You can put one scene inside another as a building block (this is called instancing)

Once you've made a "coin" scene, you can place dozens of coins in a stage. And if you later want to change how the coin looks, you only fix coin.tscn in one place, and every coin updates. This is the core of how you build things in Godot.

Add a title (Label)

Let's tidy up the Label we made last time. Select Label in the Scene dock and set it up like this:

  1. Double-click it (or press F2) and rename it to Title. Node names act as labels you'll use later to find nodes from a script.
  2. In the Inspector, open Theme Overrides → Font Sizes, check Font Size, and set it to 32.
  3. In the 2D view, drag Title to a spot a little in from the top left corner.

The rectangle outlined in blue in the 2D view is the area that's visible when the game runs. By default it's 1152 pixels wide and 648 pixels tall.

Add a character (Sprite2D)

For the character's image, we'll use icon.svg (the Godot logo), which comes with every new project. You can swap in your own art later.

  1. Select Main in the Scene dock and add a Sprite2D using the "+" button.
  2. Rename it to Player.
  3. Drag icon.svg from the FileSystem dock into the Inspector's Texture field (the one that says "<empty>").
  4. In the Inspector, set Transform → Position to x = 576, y = 480.

Position uses coordinates where the top left of the screen is (0, 0): x increases to the right, and y increases downward. Watch out, because y points the opposite way from a math graph. 576 is exactly half of the 1152-pixel screen width, so the character appears near the bottom center of the screen.

Shortcut

You can also drag an image from the FileSystem dock straight into the 2D view, and Godot creates a Sprite2D that displays it. Once you're used to it, this is quicker.

Make the coin its own scene

Next up: the coin. Since we'll place lots of coins, we'll make it a separate scene from the start.

Get the coin image

Download the coin image coin.svg and put it in your project folder (where project.godot is). When you go back to Godot, it shows up in the FileSystem dock automatically.

Instead of downloading it, you can also paste the following into a text editor like Notepad and save it as coin.svg. SVG is an image format that describes shapes as text.

coin.svg
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48">
  <circle cx="24" cy="24" r="21" fill="#f5b800" stroke="#a86b00" stroke-width="3"/>
  <circle cx="24" cy="24" r="14" fill="none" stroke="#ffe066" stroke-width="3"/>
  <rect x="21" y="14" width="6" height="20" rx="3" fill="#ffe066"/>
</svg>

Create the coin scene

  1. From the menu, choose Scene → New Scene (Ctrl + N). A new tab appears at the top of the editor.
  2. In the Scene dock, click "Other Node", then select Sprite2D and create it. This becomes the scene's root node (the node at the very top).
  3. Rename it to Coin.
  4. Drag coin.svg into the Inspector's Texture field.
  5. Press Ctrl + S and save it as coin.tscn.
The editor with coin.tscn open. The Scene dock has a single Coin node, and the coin is shown at the origin of the 2D view
coin.tscn. It has just one node, Coin, and the coin sits at the origin (0, 0)

The coin sits in the top left corner of the screen (the origin) with half of it sticking out, but that's exactly right. In a building-block scene, you keep the block's own center at the origin and let the scene that uses it decide where to put it.

Place three coins (instancing)

Use the tabs at the top of the editor to go back to main, and let's place some coins.

  1. Drag coin.tscn from the FileSystem dock onto Main in the Scene dock. Coin is added as a child of Main.
  2. With Coin still selected, press Ctrl + D (Duplicate) twice. This creates Coin2 and Coin3.
  3. Set each one's Position as follows:
NodePosition xPosition y
Coin300360
Coin2576300
Coin3852360
The editor with main.tscn open. Title, Player, Coin, Coin2, and Coin3 are listed under Main, and Coin2 is selected
The finished result for this lesson. The clapperboard icon next to Coin through Coin3 marks them as instanced scenes

Click the clapperboard icon (like the one used on film sets) next to the Coin nodes in the Scene dock to open the original coin.tscn. Instead of dragging, you can also add a coin with the chain link icon (Instantiate Child Scene) at the top of the Scene dock and pick coin.tscn.

Save with Ctrl + S and run it with F5.

The running game: the title text, a character using the Godot icon, and three coins
Here's what you'll see when you run it. Nothing moves yet
Try it: fix the block, and every copy updates

Open coin.tscn, set Coin's Transform → Scale to (2, 2), save, and go back to main. All three coins are bigger now. Once you've checked, set it back to (1, 1).

Parent-child relationships and coordinates

In the Scene dock's tree, nodes connected above and below each other have a parent-child relationship. In our scene, Main is the parent, and Title, Player, and the Coin nodes are its children.

There's one important rule: a child's Position is relative to its parent. When the parent moves, its children move along with it.

  • If you set Main's Position to (100, 0), everything shifts 100 pixels to the right (set it back to (0, 0) after you try it).
  • If you drag Coin onto Player in the Scene dock, Coin becomes a child of Player. Now when you move the character, the coin follows (undo it with Ctrl + Z after you try it).

One more thing: the lower a node is in the tree, the closer to the front it's drawn. To show the character in front of the coins, drag Player below the coins in the Scene dock.

Working with AI

If you hand this lesson's work to AI

Building a scene is easy to describe in words. Whichever approach you use, spelling out the node types, names, and positions makes it much more likely you'll get what you intended.

This is a Godot 4.7 project. In main.tscn, add three instances of coin.tscn as children of Main (Node2D). Name them Coin, Coin2, and Coin3, and set their positions to (300, 360), (576, 300), and (852, 360).
  • A (chat): here you'll mostly have the AI explain the steps. It's good at answering questions like "How do I set an image on a Sprite2D?"
  • B (Claude Code, etc.): .tscn files are text, so the AI can edit them directly. However, Godot scene files have their own format (how IDs and references are written), and sometimes a file written by AI won't load. If that happens, give the error message to the AI and ask it to fix it. If it edits a scene you have open in the editor, you'll need to reload, as explained in Lesson 1.
  • C (+ MCP): instead of writing files, the AI adds and configures nodes inside the editor. Godot saves the file itself, so format mistakes don't happen. At the end, the AI can even take a screenshot of the editor to check for itself that the layout looks right.

Even when you work with AI, you'll use the words you learned in this lesson all the time: "node," "scene," "instance," and "parent-child." Knowing them makes your requests and the AI's explanations much easier to understand.

Recap and what's next

  • A node is a building block that's good at one job. Sprite2D shows images; Label shows text
  • Nodes arranged in a tree and saved as a file make a scene (.tscn)
  • A scene can go inside another scene as a building block (instancing). Fix the original and every copy updates
  • The top left is (0, 0), and y points down. A child's position is relative to its parent
  • The lower a node is in the tree, the closer to the front it's drawn

Next time, we finally write code in GDScript. We'll move the character with the arrow keys and make the coins float.

Want AI to handle building scenes?

Godot MCP Pro is an MCP server that lets Claude Code or Cursor add nodes, set properties, instance scenes, and more, directly in the editor ($15 one-time purchase). It's fine to wait until you're comfortable building scenes by hand.

Learn more about Godot MCP Pro · How to connect Claude Code

All lessons in the series (11)
  1. Lesson 1: Installing Godot and setting up AI tools
  2. Lesson 2: Nodes and scenesYou are here
  3. Lesson 3: GDScript basics
  4. Lesson 4: Input and player movement
  5. Lesson 5: Gravity, jumping, and tilemaps
  6. Lesson 6: Signals, coins, and enemies
  7. Lesson 7: UI and screen transitions
  8. Lesson 8: Sound and game feel
  9. Lesson 9: Letting AI playtest your game
  10. Lesson 10: Exporting and publishing
  11. Lesson 11: Bonus: one-prompt games by genre