The past month I’ve been learning about the Unity game engine, reading the manual, going through tutorials, and setting up some test projects to tinker on my own. This week I finally felt comfortable enough to do a real game of my own from scratch, so I decided to start with a good old classic by building a single player Pong-like game. I call it Pingish. It has two modes: Raquetball, and Brick Breaker.
It’s not fancy, but it does make use of the most important systems in Unity.
- It uses 3D graphics for the game objects, although the view is a top down isometric view.
- It uses the UI system in worldspace to create the on-screen display of the score, ball count, and other informational messages.
- I found some free to use sound files to give it a little music and some appropriate sound effects, all in a nicely retro 8-bit game style.
- The physics engine is used in combination with some hand-rolled calculations to control the movement of the ball.
I am glad that I started with such a small project, because even as simple as it is I had a few moments of head scratching from actually trying to put Unity to use for real and finding out by experience that it doesn’t always behave the way I assumed it would. For example, the ball bounces produced by the built in physics engine seem to result in a new trajectory that is biased towards the surface normal, and after a few bounces the ball actually started bouncing back directly along the normal! I don’t know why this is, though I suspect it has something to do with the spin on the ball. It was definitely not the behavior I wanted, though, so I ended up calculating the bounce trajectory by hand.
I didn’t bother putting too much polish on it since it was mostly a learning project, but if you would like to play it you can find a WebGL version of it on this site, or you can download a zip file with the Windows build. The WebGL version has poor performance, at least in my browser.
The game uses the left and right arrow keys to control the movement of your paddle, Q quits, spacebar restarts after your game is over.
WebGL Pingish (Note: Seems to work best in Chrome. It works in Windows Firefox, but not OSX Firefox. Does not work in Safari either.)