My first prototyping project, recreating Pong in Unity, is a success! Granted, recreating a fairly simple game that every other Unity developer has done as well isn’t the craziest accomplishment, but I feel like I gained some valuable takeaways from creating this game.
Game Design Document
I realize that for many game designers, the topic of the Game Design Document (or GDD) can be controversial. Some see this document as archaic, an old school step in game design that is better left in the past.
However, with the way my brain tends to work, creating a GDD seems like it’s going to be a useful tool in designing and building games. Inspired by the article “How to Write a Game Design Document” by Leandro Gonzalez on Gamasutra, I decided that for each of my prototypes I will be assembling a simplified GDD. This is with the intent to create good habits (thinking through a game concept critically, fleshing out my roadmap, doing what I can to prevent scope creep) and getting some additional experience with this kind of planning.
I immediately realized that, at least for this simple prototype, developing a full GDD felt way overpowered. Re-explaining how a game as simple as Pong works felt a little silly, but it did give me a look into why something like a GDD might be really useful for a game that’s bigger and more complex.
Building the Game
The actual process of building this prototype was, in general, pretty smooth. I am working at staying away from any tutorials for these (as there are numerous guides for building these simple games), working on getting into the mindset of building things myself. This way, I rely less on how other developers do things, and more on learning why things work the way they do.
In reality, the biggest roadblocks I kept hitting were self-made (as they usually are in computer development). I banged my head against a wall for a while after implementing the score display system, as once it was in place suddenly the ball colliding with the scoring borders just made it bounce off. Turns out… I just forgot to update a field in the inspector. At the very least, it showed the value of setting values in the Start() method when these values won’t be changing.
Building an AI Controller
This was by far the most difficult part of the process to wrap my head around. The rest of the game is pretty straightforward, calculating points or angles based on collisions. Building a computer-controlled player seemed like it would be pretty easy, though in practice I definitely struggled.
This is the one part of the process I had to find others that did the same thing, attempting to learn from their processes as well. Surprisingly, there were few resources for building an AI player in Pong that applied to how I built my game.
I’ll admit, the solution for the AI player moving their paddle turned out rather simplistic, and they are kind of hard to beat. But it is possible, and as a prototype I didn’t want to spend a ton of time working out the details.
As the code above shows, the AI controller simply looks to see where the ball is in relation to the paddle. Then, depending on that difference, it changes the velocity of the paddle to match (using a speed modifier to prevent it from simply matching the y position of the ball).
This resulted in a functioning computer opponent that is rather hard (but not impossible) to beat.
Finishing Up and Publishing
Once I had all of the UI in place and the AI opponent working, it was time to publish! This was a simple process, setting up the build settings for the project and exporting it as a WebGL project. My main intent was to export to this format for posting here on my website, as well as publishing on itch.io to learn the ropes and requirements for that (looking towards future real experiences to publish on that platform).
Overall, while this prototype was pretty simple, I can really understand why Pong is frequently recommended as a project for beginners. Working through a game that is so familiar lets a new developer forget about dealing with the ins and outs of creating new mechanics and simply build to match mechanics they’re already familiar with. It becomes really easy to identify when things aren’t working correctly, both because I already knew how they should work and because the mechanics are so simple.
Some other lessons learned:
- Building a simple GDD can really help lay out how a game should work and look, helping solidify concepts in your head (likely a full post on why the GDD isn’t dead coming in the future)
- Using the GDD as a basis for creating tasks/stories (and then loading them all into a project management system) took the whole project and broke it down into manageable chunks, letting me work through them in a logical order
- While this prototype didn’t require it, after working through this I can really see why building a true prototype of a game before doing anything more (graphics, fancy effects, etc) is critical. Prove out your concepts and controls first before spending too much time thinking about aesthetic.
- Don’t underestimate the complexity and impact of creating a well-built AI system. While my version of Pong is definitely playable, I wouldn’t call the AI advanced. I plan to spend some time working though these prototypes on polishing my skills and understanding around AI concepts, since this is something that could really enhance the player’s experience.
- I still don’t understand the formatting of a game for multiple screen sizes and shapes. I built the game board at a totally arbitrary size of 750px by 500px, but I really had no reasoning for doing so. Setting up the Unity environment and my game assets to flex and fit more screen resolutions would definitely be time well spent.
Final Product & Next Up
If you’re up for a rousing game of Pong (or, rather, Definitely Not Pong), click here to launch it in a new window!
With this first foundational prototype complete, my next focus will be on another simple concept, and one where AI comes less into play: the ‘dodger’ genre. Objects will be randomly flying at a player-controlled character, and the player must react quickly to dodge these obstacles.
Keep an eye out for the project kickoff post soon!