In Lesson 8, we added sound and effects, and the game became fully playable. Now playtesting matters. The person who made a game assumes "it should work like this," so it's surprisingly easy for them to miss bugs. In the first half of this lesson, you'll learn ways to test that work without MCP: a checklist, print, the debugger, and a small automated test. In the second half, we'll show, exactly as it happened, how Godot MCP Pro lets AI run the game itself, look at the screen, and find and fix a bug.
Finished project for Lesson 9: project-lesson09.zip (380 KB)
What playtesting checks
Playtesting isn't just playing. It's checking, one by one, that things work the way they should. For this game, that means things like:
- Touching a coin makes it disappear and adds 1 to the score (all 6 can be collected)
- Hitting an enemy costs a life and sends you back to the start
- 0 lives means game over, collecting everything means a clear, and you can play again from there
The methods in this lesson are ordered from "done by hand" toward "handed off to a system."
| Method | Good at | Not so good at |
|---|---|---|
| Playing with a checklist | Whether it's fun, whether it's too hard, anything that looks or sounds off | Doing it all every time is a lot of work. Things get missed |
print | Shows right away whether the code reached a line, and what a value was at that moment | Too much output becomes unreadable. You have to remove it later |
| Debugger | Lets you look inside the running game, with or without pausing it | You have to figure out what to look at yourself |
| Automated test | Repeats the same checks instantly, as many times as you like | Only checks what you wrote |
| AI playtesting (MCP) | You can hand off the whole run of playing, looking, investigating the cause, and fixing | Can't judge whether it's fun or how it feels |
A checklist for playing it yourself
First, play it by hand. Rather than playing however the mood takes you, write down what to check beforehand, and you'll miss less. Here's an example checklist for this game. Copy it into a text file and go through it again every time you fix something.
- "Start" on the title screen starts the game
- You can walk left and right. You can't leave through the walls
- You can jump. How long you hold the button changes the height. You can get onto every platform
- All 6 coins can be collected (check them one at a time to make sure none can't be grabbed)
- The same coin never adds to the score twice
- Hitting an enemy costs a life and sends you back to the start. Three hits is game over
- Collecting everything shows the clear screen. The time and best time are correct
- You can play again from the result screen (the second time, the score starts from 0 again)
- The sounds play. The BGM loops. No errors appear in "Output" or the "Debugger"
The key is not just playing well, but also doing weird things on purpose. Mash the jump button, run into enemies over and over, keep walking into a wall. Bugs hide in the actions the maker assumed "nobody would do."
Peek inside with print
The easiest way to investigate is print(). It lets you show "did the code reach this line?" and "what was the value at that moment?" in the Output panel at the bottom of the editor. For example, if "grabbing a coin doesn't increase the score," add one line at the top of _on_coin_collected in main.gd, just while you're checking.
print("Got a coin. Current score: ", GameState.score)Run the game, grab a coin, and see whether this text appears in Output.
- It appears: the signal is arriving fine. The problem is after this point (calculating or displaying the score).
- It doesn't appear: the function isn't being called at all. Suspect the signal connection or the coin's collision (layers and masks).
Used this way, print is a tool for narrowing down where the problem is by finding "how far things are working correctly." Once you're done checking, remove the line (if you leave it in, the messages you actually want to see get buried).
The debugger and the "Remote" scene tree
Watch the running game in the Remote scene tree
While the game is running with F5, a Remote / Local switch appears at the top of the Scene dock in the top left.
- With the game still running, go back to the editor and click Remote.
- You'll see a list of the nodes in the game that's running right now. Select
PlayerunderMain. - The Inspector shows the live Position and Velocity. The values change as you walk and jump.
"Local" is the scene you're editing in the editor (the contents of the file). "Remote" is the contents of the running game. You can also see a Coin disappear from the Remote list when you grab it. If you change a value in the Inspector, the game picks it up right away (for example, set Player's Speed to 600). However, it goes back when you stop the game. When you find a value you like, write it into the Local scene or the script.
See collisions with your own eyes
Turn on Debug → Visible Collision Shapes in the menu before running, and the collision shapes are drawn in color on the game screen. When "it's touching but nothing happens" or "it gets caught on empty space," start by checking the shapes and their positions this way.
The Debugger panel and breakpoints
The Debugger tab at the bottom of the editor has Stack Trace, Errors, Profiler, Monitors, and more. Errors and warnings raised while the game runs are logged under Errors, along with which file and which line they came from. If you see a red number, always open it and read it.
When you want to dig deeper, use a breakpoint. Click to the left of a line number in a script and a red dot appears (or press F9, "Toggle Breakpoint"). When the game reaches that line, it pauses there, and Stack Trace lists the values of the variables at that moment. "Step Over" moves forward one line at a time, and "Continue" resumes the game. You don't have to add and remove print lines, so it's handy once you get used to it.
Write a small automated test
Testing by hand matters, but redoing everything after every fix is a lot of work. So we'll write a script that runs the game automatically and checks it. The test we'll build starts the game, walks right, jumps, checks each time that "things are the way they should be," and prints the results as OK / NG (not good).
Create the test script
- In the FileSystem dock, right-click
res://and choose Create New → Folder... to make a folder calledtests. Keeping the tests separate from the game's own files makes it easy to say "leave the tests out" when we export in the next lesson. - Right-click
testsand choose Create New → Script.... TypeSceneTreeinto Inherits:, set the path tores://tests/test_game.gd, and click Create. - Delete everything in it, paste in the following code, and save.
extends SceneTree
# Automated test for Hop Hop Coins.
# Runs the game and, at set times, checks that things are the way they should be.
# See Lesson 9 for how to run it (start Godot with --script)
# Time since the test started (seconds)
var time: float = 0.0
# Which check we're on right now
var step: int = 0
# Number of checks that failed
var failed: int = 0
var player: CharacterBody2D
var start_x: float = 0.0
var start_y: float = 0.0
# Called once when the test starts. Opens the game scene
func _initialize() -> void:
change_scene_to_file("res://main.tscn")
# Called every frame. Returning true ends the test
func _process(delta: float) -> bool:
time += delta
if step == 0 and time > 1.0:
step = 1
player = current_scene.get_node("Player")
check("Player is standing on the floor", player.is_on_floor())
var coins: Array[Node] = get_nodes_in_group("coins")
check("There are 6 coins", coins.size() == 6)
for coin: Node in coins:
# If mask bit 2 (player) isn't on, the player can touch the coin but can't collect it
check(coin.name + " can detect the player", coin.get_collision_mask_value(2))
# Start walking right (this is the same as pressing the key)
start_x = player.position.x
Input.action_press("move_right")
elif step == 1 and time > 3.6:
step = 2
Input.action_release("move_right")
check("Walked to the right", player.position.x > start_x + 600.0)
# A test script can't just write GameState, so we look it up from root
var game_state: Node = root.get_node("GameState")
check("Collected the coin along the way", game_state.score == 1)
# Press the jump button
start_y = player.position.y
Input.action_press("jump")
elif step == 2 and time > 3.8:
step = 3
Input.action_release("jump")
check("Jumping moved the player up", player.position.y < start_y - 60.0)
elif step == 3 and time > 5.0:
check("Landed on the floor again", player.is_on_floor())
if failed == 0:
print("All OK!")
else:
print("%d check(s) NG" % failed)
# End the test, using the number of failures as the "exit code" (0 means success)
quit(failed)
return false
# Print OK if ok is true, NG if it's false, and count the failures
func check(what: String, ok: bool) -> void:
if ok:
print("OK ", what)
else:
print("NG ", what)
failed += 1- A script that says
extends SceneTreeisn't attached to a node. Instead, it becomes what runs the whole game._initialize()opensmain.tscn, and_process()is called every frame. stepis "which check we're on right now." Oncetimepasses 1 second we do the first check, once it passes 3.6 seconds the second, and so on, moving through them in order, split up by time. Just like the enemy's back-and-forth from Lesson 6, we're managing the order with if statements and a variable.Input.action_press("move_right")makes the same thing as pressing the key happen from code.player.gdcan't tell whether it's a real key or not, so the player moves the same way as when a person plays.get_collision_mask_value(2)returns whether "mask bit 2 (the layer we namedplayerin Lesson 5) is on." In Lesson 6 we set the coins' mask toplayer, and the test checks that too.- In a regular script, you can use the autoload
GameStatedirectly by name. But in this kind of test, the script is loaded before that name becomes available, so we look it up withroot.get_node("GameState"). quit(failed)closes Godot, using the number of failures as the exit code. 0 means success. Later, when you run tests automatically with something like GitHub Actions, this number decides pass or fail.
Run the test
You don't run this test with F5 in the editor. Instead, you start Godot from the command line. The zip you downloaded in Lesson 1 contains two files: Godot_v4.6.2-stable_win64.exe and Godot_v4.6.2-stable_win64_console.exe. We want text output, so use the console one.
- In the FileSystem dock, right-click
res://and choose Open in File Manager. Your project folder opens in File Explorer. - Type
cmdinto File Explorer's address bar and press Enter. A Command Prompt opens in that folder. - Enter the following command. Replace the
C:\Godot\part with wherever you put Godot (dragging the exe from File Explorer into the Command Prompt fills in the path for you).
C:\Godot\Godot_v4.6.2-stable_win64_console.exe --path . --script res://tests/test_game.gd/Applications/Godot.app/Contents/MacOS/Godot --path . --script res://tests/test_game.gd--path . means "use the project in the current folder," and --script means "run this script instead of the main scene." The game window opens, the character walks right on its own, grabs a coin, jumps, and the window closes after about 5 seconds. The Command Prompt shows this:
OK Player is standing on the floor
OK There are 6 coins
OK Coin can detect the player
OK Coin2 can detect the player
OK Coin3 can detect the player
OK Coin4 can detect the player
OK Coin5 can detect the player
OK Coin6 can detect the player
OK Walked to the right
OK Collected the coin along the way
OK Jumping moved the player up
OK Landed on the floor again
All OK!When it finishes, you may see a line like WARNING: ObjectDB instances leaked at exit. It's a notice that appears because the test ended the game partway through, and it has nothing to do with the test results.
Break it on purpose and see whether the test catches it
You find out whether a test is really useful by checking whether it says NG when something is broken. In main.tscn, select Coin4 (the coin on the ground), and in the Inspector under Collision → Mask, turn 2 off and 1 on. Save, then run the test again.
OK Coin3 can detect the player
NG Coin4 can detect the player
OK Coin5 can detect the player
OK Coin6 can detect the player
OK Walked to the right
NG Collected the coin along the way
OK Jumping moved the player up
OK Landed on the floor again
2 check(s) NGTwo checks come back NG, and you can even tell which coin is the problem. Once you've seen it, put the Mask back the way it was (only 2 on). When you change a value on an instance, a "revert" arrow appears next to the property, and clicking it is the easiest way.
- Add a check of your own, like
check("Has 3 lives", ...). You can test it withgame_state.lives == 3. - You can also use
Input.action_press("move_left")to walk left and write a test that checks "the player doesn't leave through the wall (player.position.x > 0)." - When you want to write tests seriously, there are testing add-ons called GUT and gdUnit4. The approach in this lesson is a first step toward them.
Letting AI playtest with Godot MCP Pro (a real session)
From here on, we're using approach "C: AI + MCP" from Lesson 1. With Godot MCP Pro installed, an AI like Claude Code can run the game in the editor, send key presses, look at the screen through screenshots, and read the values of nodes in the running game. In other words, the AI can run the same playtesting loop you did by hand in the first half, by itself.
What follows is a record of a real session carried out while writing this lesson. In a copy of the finished Lesson 8 project, we planted one bug on purpose by setting Coin4's mask wrong, and told the AI (Claude Code) only "playtest the game and fix anything that looks wrong." The session used the Japanese version of the project, in Godot 4.6.2 with the editor in Japanese, so the game's text and the screenshots below are in Japanese. Some tool results have been trimmed for readability.
Setup
- Put the Godot MCP Pro add-on (
addons/godot_mcp/) into your project, then in Project → Project Settings... → Plugins tab, check Enable for Godot MCP Pro. - Register the MCP server with Claude Code. The steps are in How to use Claude Code with Godot 4.
- To check that it's connected, ask the AI to "show me the project info."
project_name: "ぴょんぴょんコイン"
project_path: "D:/dev/godot_projects/godot-learn-ja/scratch_lesson09/mcp_session/"
godot_version: "4.6.2-stable (official)"
main_scene: "res://title.tscn"
renderer: "gl_compatibility"
autoloads: GameState, MCPGameInspector, MCPInputService, MCPScreenshotThe project name is the Japanese title of this same game. MCPGameInspector and the others are autoloads the plugin adds automatically so it can inspect the running game. They go away when you disable the plugin.
1. Run it, walk, and look at the screen
The AI first ran the game scene, held the right arrow key for 2.5 seconds, and walked the player to the coin on the ground.
play_scene(mode="res://main.tscn") → playing: true
simulate_key(keycode="KEY_RIGHT", duration=2.5) → sent: true (released automatically after 2.5 seconds)
get_game_screenshot() → screenshot (the image below)
From this image, the AI noticed that "the player overlaps the coin, but the coin hasn't disappeared and the score is still 0 / 6." The picture alone doesn't show the cause, so next it went to read the values of nodes in the running game.
2. Read the values and narrow down the cause
/root/Main/Coin4 collision_layer: 4, collision_mask: 1, monitoring: true, position: (900, 459.1)
/root/Main/Player collision_layer: 2, collision_mask: 1, position: (915, 484.0)
/root/Main/Coin collision_layer: 4, collision_mask: 2The positions really do overlap (x is 900 and 915), and the coin is watching (monitoring: true). The only difference is that Coin4's mask is 1. The other coins have 2. To be sure, the AI ran a script inside the game and checked all the coins at once.
for coin in get_tree().get_nodes_in_group("coins"):
_mcp_print("%s mask=%d player_bit=%s" % [coin.name, coin.collision_mask, coin.get_collision_mask_value(2)])
_mcp_print("score=%d" % get_tree().root.get_node("GameState").score)Coin mask=2 player_bit=true
Coin2 mask=2 player_bit=true
Coin3 mask=2 player_bit=true
Coin4 mask=1 player_bit=false
Coin5 mask=2 player_bit=true
Coin6 mask=2 player_bit=true
score=0It also checked for errors with get_editor_errors: there were none. In other words, this is a bug that doesn't produce an error. Mask 1 is world (the floor and tiles), so Coin4 notices the floor but not the player (layer 2). The AI's conclusion: "Only the Coin4 instance in main.tscn has collision_mask overridden to 1. Setting it back to 2 will fix it." It's the same cause that made the automated test in the first half say NG.
3. Fix it, then check again with the same input
stop_scene() → stopped: true
open_scene(path="res://main.tscn") → opened: true
update_property(node_path="Coin4", property="collision_mask", value=2)
→ old_value: 1, new_value: 2
save_scene() → saved: true
play_scene(mode="res://main.tscn")
simulate_key(keycode="KEY_RIGHT", duration=2.5)
get_game_screenshot() → the image below
Finally, the AI tried jumping too. Reading Player right after simulate_action(action="jump", pressed=true) showed velocity.y: -580 (moving upward). With the checks done, it stopped the game with stop_scene(), and in the saved main.tscn, Coin4's collision_mask = 1 line was gone (the value was back to the original, so the override was no longer needed).
This whole flow is the same as what you did by hand in the first half: run → play → look at the screen → read values to narrow down the cause → fix → check again with the same input. MCP is a tool that lets the AI go around this loop on its own. For more on testing with AI (run_test_scenario, assert_node_state, capture_frames, and so on), see AI playtesting in Godot 4.
What AI playtesting can't do
Reading that session, it might seem like AI can do anything, but there are clear limits.
- It can't tell whether the game is fun: whether the jump feels good, whether it's too hard, whether the sounds are annoying. People decide that by playing.
- It only sees "moments": a screenshot is a single still image. Bugs that happen in the middle of a movement get missed unless you use a series of images (
capture_frames) or a record of values. - Its input timing isn't as precise as a person's: tool calls take time, so moves like "press right exactly at the top of a jump" are hard for it. Measuring time inside the game, like the automated test does, is more reliable.
- It sometimes makes the wrong "fix": this time there was only one cause, but AI can also change something else and say "it's fixed." Always read what it changed (the diff), and play it yourself to check.
We recommend splitting the work like this: routine checks go to automated tests, searching and fixing go to AI, and the final call is yours.
Common pitfalls
| Symptom | Cause and fix |
|---|---|
| Running the test shows no text at all | You're using the Godot that isn't _console.exe. Run it with the console exe. |
Identifier not found: GameState | Autoload names can't be used directly in the test script. Look it up with root.get_node("GameState"). |
| The test never ends, or doesn't check anything | Make sure the first line is extends SceneTree. Scripts for nodes (extends Node and so on) don't work with --script. If it won't end, close the window or stop it with Ctrl+C. |
| "Walked to the right" comes back NG | If the computer running the test is slow, the wait time may not be long enough. Try making the number in time > 3.6 a bit bigger. |
| "Remote" doesn't show up while the game is running | It only appears while the game is running. Run the game, then go back to the editor and look for it. |
| You changed a value in Remote, but it's back to the old value the next time you run | Remote changes only last while the game is running. Fix the value in the Local scene or the script. |
| The AI says it "can't connect to the Godot editor" | The editor isn't open, the plugin is disabled, or it's connected to an editor for a different project. Enable the plugin, and check that project_path in get_project_info is the project you want. |
Working with AI
When you ask for tests, listing "what you want to check" in sentences turns straight into a list of checks. The easiest way is to hand over the checklist from the first half.
- A (chat): it's good at drafting checklists and test scripts, and at explaining what error messages mean. It can't run the game, so you run it and paste in the results.
- B (Claude Code, etc.): it can write the test file, start Godot from the command line to run the test, read the NG lines, and go as far as fixing them. But it can't see the screen, so it can't find bugs where "something looks wrong."
- C (+ MCP): as in this lesson's real session, with Godot MCP Pro the AI can run the game with
play_scene, control it withsimulate_key/simulate_action, look at the screen withget_game_screenshot, read values withget_game_node_propertiesorexecute_game_script, fix things withupdate_property, and check again with the same input. Withget_editor_errorsandget_output_log, it can also read errors and print output.
Whichever approach you use, when the AI says "it's fixed," read what it changed and play it yourself to check. AI testing only checks "what was written and what was seen."
Recap and what's next
- Playtesting means checking, one by one, that things work the way they should. Make the checklist first
- Use
print()to narrow down "how far things are working correctly" - While the game runs, the "Remote" scene tree shows the values in the running game. "Visible Collision Shapes" lets you see collisions
- Read "Errors" in the "Debugger." Use breakpoints to pause and look at variables
- A script with
extends SceneTreeplusInput.action_presslets you rerun the same checks automatically, as often as you like - With Godot MCP Pro, AI can go around the loop of running, playing, looking at the screen, investigating, fixing, and checking again. The final call is yours
Once it passes the tests, it's finally time to let other people play. Next time: exporting and publishing. We'll export a Windows executable and a web version that runs in the browser, and walk through publishing on itch.io.
Want AI to run your playtests?
With Godot MCP Pro, Claude Code or Cursor can run your game, send key presses, look at screenshots and live values, fix bugs, and check again (190 tools, $15 one-time purchase). You can finish this series without MCP.