In the Grand Theft Auto games you can drive around in replicas of cities like New York, Miami, San Francisco, and so on.
That’s all very nice, but driving around in your own neighbourhood would be just so much cooler. Unfortunately, I think it is unlikely that Rockstar will ever make a game in the place where I grew up.
So if they don’t do it, I might as well do it myself.
First of all, it’s time to lower the expectations:
- According to Wikipedia, Rockstar games used a 1.000 person team to develop GTA V, and it took them a couple of years to do this.
- I’m just a single person team, and I can only spend some of my free time on it.
So instead of trying to surpass GTA V, I tried something in the lines of the first 2D top down GTA games.
Step 1: the engine
I didn’t have the intention to code everything from scratch, so I had a look at the Unity engine.
I started off with the UFO tutorial. In the tutorial, you go through all the basic steps that you’ll also need for a GTA game:
- Using sprites
- Collision detection
- Basic physics
Step 2: the map
I considered briefly to create a map of my town myself, but that would just be too much work.
Luckily, I found a better option. The Flemish government offers high quality aerial pictures for free on their download site. The images are huge, but I managed to crop the necessary area with specialized imaging software.
Of course, this approach has some drawbacks:
- There are cars and pedestrians in these aerial pictures, and it would be a lot of work to edit them out.
- These images are purely 2D. So this doesn’t work very well in case of bridges and tunnels.
On the other hand, it can’t get any more realistic!
Step 3: bringing it all together
I loaded this image in Unity as my scene background. Based on the UFO tutorial, it wasn’t too hard to add a driving car to the game as well.
But if you run the game like this then your car drives straight through all the houses!
Time to add some collision detection. And there comes the problem: this is a manual job in Unity, and it is a huge work. You have to trace all the streets one by one (the green lines). Furthermore, Unity doesn’t support this well in such a small level of detail.
So I started off by adding collision detection for a small part of the map, kinda like a proof of concept.
After that, I added some further details:
- Motor sounds when the car is driving
- Walking pedestrians
- Some target icons
- And a score that increases when you hit a pedestrian or a target
Step 4: play the game
Here you can a gameplay video:
Note that the car is controlled via the mouse movements: the front of the car follows your mouse pointer, and the left mouse button takes care of the acceleration.
You can see the score in the top right corner.
Actually I’m quite happy with the result, especially given the fact that I’m not Rockstar.
What you have seen so far is not really a full game. It’s more like a proof of concept.
If you want to make this a full game, then you need to add a lot more:
- A story
- Different missions
- A bigger map
- Extra traffic and pedestrians
- Better controls
- The possibility to get out of the car
- A minimap and a quest pointer
- Sound effects and music
All of them nice features, but a LOT of work to implement them. Especially the bigger map (and all the collision detection work that comes with it) are simply too much.
So I’ll stick with my proof of concept for now, and keep on hoping that Rockstar will come with a surprise someday…