Can ChatGPT Write Game Code? Yes, With One Catch
Yes, ChatGPT can write working game code, from small browser games to single features for Godot, Unity or Unreal. The catch is that it writes from memory, so it may use something your version of the engine does not have, and it sounds just as sure when it is wrong.
None of that makes it useless. It means you need to know which jobs to trust it with and how to catch the mistake quickly.
Which jobs is it good at?
This is a rule of thumb from how chat tools work, not a measurement.
| Job | How it usually goes | Why |
|---|---|---|
| Rules you can state exactly, such as scores, timers, inventories | Well | The task is fully described in your message |
| Explaining an error you paste in | Well | It has the exact words in front of it |
| Calling engine features | Risky | Engines change between versions, and its memory may be older than yours |
| How something feels, such as a jump or a screen shake | Poorly | It cannot play, so you are its only eyes and hands |
| Changes across many files | Poorly in a plain chat | It only sees what you paste |
So a loot table or a stamina bar is a fine thing to ask for. "Make my boss fight feel weighty" is a conversation you will have to steer, round by round.
The invented-function trap
Say you are building Ice Hole Tycoon, a made-up game about running an ice-fishing shop. You want a caught fish to wiggle, so you ask ChatGPT, and it gives you tidy code with a line like fish.wiggle_smooth(0.4).
It reads well, and the name makes sense. The game then stops with an error saying no such function exists, because ChatGPT produced something that sounded right. We made that name up too, to show the pattern: real cases look just as believable. The same thing happens with functions that did exist two versions ago.
Asking "are you sure?" does not help much, because it will often just agree or apologise and offer another guess. What helps is to make it point at something you can look up.
Three habits catch nearly all of this:
- Name your engine and exact version at the start of every chat. "Godot" is not enough. The number is on the engine's start screen.
- Paste the whole error, word for word. Your summary of an error throws away the part it needs.
- Ask where a function is documented, then open that page. If the page does not exist, you have your answer, and it took a minute.
For a whole browser game in one go, see the one-file method. And whatever it writes, the origin of what goes into your game stays your job, so read Can you copy game mechanics? if you are modelling something on another game.
Paste this to your AI
I use [engine] version [exact number]. Write the code for this one feature: [your feature].
If the feature passes through more than one situation, such as hooked, wiggling, landed and escaped, start with a Mermaid diagram of those situations and what moves between them. Check that each one has a way out and that nothing can fire twice by accident, then write the code from that diagram.
Before the code, also list every engine function or class you plan to use, each with the page of the official documentation for my version that describes it. If you cannot name the page, or you only remember it from an older version, write "unsure" next to it and tell me how I can find out. Do not swap in a name that merely sounds right.
After the code, say where it goes and what I should see when I run it. If I paste an error back, quote the exact words you are reacting to before you suggest a fix.
Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP
How to check it worked
- Open two of the named pages. They should exist and describe what the AI said they describe.
- Look at the "unsure" marks. A long list with none at all deserves a second look.
- View the diagram at mermaid.live. Mermaid is text that becomes a picture. Ask yourself what happens if the fish escapes while it wiggles. If no arrow covers that, neither does the code.
- Run the feature twice. Restart the game between runs, because some mistakes only show up the second time.
- Paste an error and read the reply. It should begin with the quoted words. If it jumps straight to a new version of the code, ask again.