'Open'AI recently released their new AI chat model, ChatGPT for people to experiment with. I had a go with it and was astonished at what I found. As well as being able to answer questions, write poety and articles, you can ask ChatGPT questions about programming and it will answer them, and even include sample code. Even more astonishingly, the same code will normally compile and run.

This is an experiment to find out to what extent ChatGPT could help someone with very little experience make a very simple game in Unity.

I am of course, cheating. I first started programming in BASIC almost 40 years ago, and I have been using Unity for over a decade. However, I thought I would try and ask questions that could feasibly be asked by a rank beginner.

The game I chose to make is called 'Happy Mrs Chicken', which is a very simple little game based on one that appears in an episode of Peppa Pig. I like to use it as the first game I ever make in a new system because of its simplicity. Basically the details are:

  • It's a 2d game
  • You control Happy Mrs Chicken, and she will snap to whereever you click on the screen*
  • When Happy Mrs Chicken moves, she also lays an egg
  • You get one point for every egg Happy Mrs Chicken lays.

* In the video, Happy Mrs Chicken is moved to a random position by pressing any key, the move-by-mouse variant is my preferred version, though.

I used DALL-E to create both the sprites.

How things went

Pretty well, I think. There were a couple of places where ChatGPT gave me incorrect instructions and wasn't able to properly help me out with my problem. The first of these was when it gave me the incorrect filename for a class it wanted me to create, which didn't match the name of the class in the file. I gave it all the error messages I was getting back, but it wasn't able to make the leap. In some ways this is falling at the first hurdle, but it wasn't an error it made again.

When it came to problem solving, I thought its results were mixed. The first script it wrote to move Happy Mrs Chicken to the mouse cursor didn't quite work - it moved Happy Mrs Chicken, but her z position was the same as the camera's and she therefore wasn't visible - not a problem ChatGPT was capable of diagnosing. The 'worldPosition.z = 0;' line was the only line of code I wrote myself. On the other hand, it did come up with another feasible possible source of the problem in that perhaps we should be using ScreenToViewportPoint instead of ScreenToWorldPoint? (Actually no, but it was a good guess)

One of the things we never implemented was the little jump HMC does every time she lays an egg. I tried doing this, but ChatGPT was obsessed with adding rigidbodies to everything. For a while it was stuck in a loop, giving me instructions on adding a rigidbody on every answer that it gave, which was very strange.
I feel like a novice might have got in to real trouble at this point (although it's also possible ChatGPT would have ended up helping them make a cooler looking game? who knows?) I had noticed for another piece of code I'd asked it to do that it seemed over-keen to add rigidbodies to things.

Anyway, the whole process from conception to uploading to itch.io took under two hours, and included things like me asking ChatGPT how to remove backgrounds from images using Krita.


Conclusion

I would love to see what would happen if a genuine novice was given ChatGPT to make their own little game with. My feeling is that they would occasionally need someone experienced with Unity to step in and help them, but I am stunned by how much ChatGPT got right.

DALL-E made all the art, with a little bit of simple cleanup by me.

ChatGPT wrote all the code, except for one single line.

If you look right at the top of this page, there is a link you can follow to read the ChatGPT transcript.

StatusReleased
PlatformsHTML5
AuthorTimAidley
Made withUnity