2. Let's Start with the Sky – Unity 3.x Game Development by Example

Chapter 2. Let's Start with the Sky

So, you've downloaded and cracked the seal on a fresh copy of Unity. You've seen some examples of what other people have done with the game engine, and you've taken a whirlwind tour of the interface. You can clear out the AngryBots Demo project by clicking on File | New Project in the menu. After choosing a folder for the new project (you can call it "Intro"), Unity may close down completely and start up again. Once it does, you're left staring at a 3D plane.

Click the little landscape button at the top-middle of the Scene view to see this plane. It stretches on forever in all directions seemingly infinitely to either side of you, ahead of you, behind you, straight down to the deepest depths, and straight up to the sky. It's time to build a game, right? But how do you start? Where do you start?

That little lightbulb

The idea's the thing. Every game starts with an idea that little lightbulb above your head that flicks on all of a sudden and makes you say "aha!" If you've gone as far as picking up a book on Unity, you probably have at least one game idea floating around in your noggin. If you're like me, you really have 10,000 game ideas floating around in your head, all clamoring for your attention. "Build me! Build me!" Which of these ideas should you go ahead with?

The quality that defines a successful game developer is not the number of ideas he has. The guy with ten game ideas is equally as valuable as the girl with 500 game ideas. They're both essentially worthless! A game developer develops games. The one thing that separates you from success is not the number of ideas you've had or the number of projects you've started and abandoned. It's the games you've finished that count. To put it another way: he who executes, wins. Don't worry about getting it right just yet; worry about getting it done.

And what's with all this pressure to make your first game good, anyway? Before he directed Titanic and Avatar, James Cameron worked on the sequel to Piranha a zero-budget, B-movie schlockfest about murderous fish. Don't worry you'll be the game world's answer to Cameron some day. But for now, let's finish the fish.

The siren song of 3D

The biggest barrier to your success as a Unity game developer is finishing a project. The idea stage that you enter when you sit staring at that endless 3D plane is crucial to you overcoming that barrier. If you choose the right idea, you will have a much better shot at finishing. Choose the wrong idea, and you might crash and burn. Then you'll probably go back to school and study to be an accountant. Starting in game development and ending in accounting is your worst case scenario. Let's avoid that at all costs.

Before you even begin, the odds are stacked against you. That endless 3D plane is calling you, begging you to start a project that's way over your head. You may begin thinking of the other 3D games you've played: gritty, wide-open "sandbox" games like Crackdown or Grand Theft Auto; tightly-controlled platformer games with lots of exploration and interesting challenges like Super Mario 64; sweeping, epic role-playing games like Fable or Fallout 3. All of these games have a few things in common: an animated character or first-person camera moving around in a physics-based environment; a rich and detailed 3D world with maps, quests, non-player characters, and pick-ups; and teams of hundreds of people burning through multimillion dollar budgets.

Odds are that you're not reading this book with 99 of your closest, wealthiest friends who all want to help you build your game. You need to ignore the dizzying and endless scope that eternal 3D plane implies, and foster the creativity and resourcefulness that will get you from point A to point B; that is, from an idea to a finished game.

Features versus content

Another trap that fledgling game developers fall into is reducing the scope of their ideas in ways that still prove the project impossible. For example, they'll say: "I don't want to set my sights too high, so I'm going to make a game like Gran Turismo, except with fewer cars," or "I want to make Diablo with smaller levels," or "I'm going to build World of Warcraft with fewer classes and about half the items."

To understand why this approach is so dangerous is to understand a little more about how games are put together. The two issues here are features and content. All things being equal, a game with 50 levels has more content than a game with five levels. The 50-level game has ten times more content, but both games have the same feature: levels. A role-playing game with 12 character classes has more content than a game with three character classes, but they both have the same feature: character classes.

So, while you may recognize that it's more work to build additional content for a game, try to peer behind the curtain and recognize the number of features that go into a game. Every feature that your game supports takes more work, and sometimes it's easier to build 20 different enemies for a game than to actually build the enemies feature.

A game with no features

We see how it can be dangerous and self-defeating to choose a game with many features and reduce the amount of content in that game. And, because some features are so time-consuming to develop, it's also dangerous to choose a fully featured game and start stripping features to reduce the scope of our project.

A much better approach, and one that you'll have much more success with, is to start with a game that has zero features, and then add them slowly, one by one. Using this approach, you can decide when your game is good enough to unleash on your players, and any additional features you had planned can go into the sequel. This is a winning approach that will see you through many small victories, and many finished games!

Mechanic versus skin

One skill that may help you finish is recognizing the difference between mechanic and skin. Your game's mechanic is how it physically functions. The very best games contain a simple mechanic that's easy to learn, hard to master, and compelling enough to keep a player interested. The mechanic in Tetris is to move and rotate falling blocks into place to create one or more solid lines. The mechanic in many golf games is to simulate swinging a golf club by moving the controller's thumbstick around or tapping a button when the "Power" and "Accuracy" meters are at the right level. The mechanic in Breakout is to move a paddle back and forth to bounce a ball into a wall of fragile bricks.

A game's skin is how it looks and sounds. It's the animated cutscenes that establish a story. It's the theme that you choose for your game. Imagine a game where you've programmed an object to follow the mouse cursor. There are "bad" objects on the screen that you must avoid, and "good" objects on the screen that you must collect. That's the game mechanic. The game skin could be practically anything. The player object could be a mouse collecting "good" cheese objects and avoiding "bad" rat objects. Or it could be a spaceship collecting space gold and avoiding black holes. Or it could be a fountain pen collecting verbs and avoiding conjunctive pronouns. As they say, "the sky's the limit!"

Trapped in your own skin

The advantage that you gain by separating mechanic from skin is that you can shuck off video game conventions and free yourself to develop anything you want. If you think, "I'd like to create a space-themed strategy game", and you think back to all of the space-themed strategy games that you've played, you might think of 4X games like Alpha Centauri or Master of Orion they both pit you in a massive quest to conquer the universe. They are huge games that you likely won't finish alone. So, you start trimming them down for sanity's sake "I'll just build Master of Orion with fewer planets," or "I'll just build Alpha Centauri with fewer features." Now you've unwittingly fallen into that self-defeating trap. Your project is still too huge. You eventually abandon all hope. A few years later, you're an accountant wondering what might have been.

That singular piece of joy

Instead of going down that doomed copycat road, start asking yourself questions about the outer space theme and the strategy mechanic. What's fun about each of them? Which moments in a game like Master of Orion really turn your crank? Do you like mining a planet for resources and buying new stuff? Do you like the thrill of discovering a new planet? Or maybe building an armada of spaceships and conquering enemies really get you excited?

Distill your game down to that one thing that singular piece of joy. Create that one joyful experience for your player, and nail it. That's your game. Everything else is just feature creep.

One percent inspiration

The Internet is packed with small, simple, and free-to-play games that offer the cheap thrill of a singular piece of joy. Let's analyze some of these games to see what we can learn. For each example, we'll identify:

  • The core game mechanic that singular piece of joy

  • The skin

  • The feature set

  • Possible additional features

  • Alternate skin ideas

These games require the Flash Player plugin, which you probably already have. If, for some weird reason, your computer's been living under a digital rock and you need to install it, browse to http://get.adobe.com/flashplayer/ and follow the instructions there.

Motherload

Motherload by XGen Studios (http://www.xgenstudios.com/play/motherload) distills a complicated 4X game, like Master of Orion, down to two joy-inducing tasks: mining for resources and shopping for stuff.

The core mechanic: Pilot your vehicle by using the arrow keys dig, fly, and avoid long falls with a finite fuel source. There's only one real "level" in the game, and it stretches down your screen for a loooong time. Your drill-enabled vehicle can only dig down so deep and dig up so many pieces of ore before having to return to the surface to sell off the goods and clear some cargo space. The trick is to dig up and sell enough ore to upgrade your ship so that it can dig deeper, carry more loot, and survive longer falls. The initial goal is to rack up ludicrous cash, but a story eventually develops that adds meaning to your loot-lust. This mechanic is similar to the much simpler game Lunar Lander, where the player must gently land a spacecraft on a single non-scrolling screen with limited fuel. You can look at Motherload as either a dramatically toned-down Master of Orion or a trumped-up Lunar Lander!

The skin: A quasi-cartoony space mine with a layer of grit and grime over it. The player character is a futuristic mining vehicle. The only non-player character is a human being (… or is he?).

The feature set:

  • Vehicle control

  • Vehicle upgrades (which include both vehicle and terrain strengths and attributes)

  • Shops

  • Diggable terrain

  • Scrollable story or Dialog windows

  • Save game

  • Front-of-house features

Note

Front-of-house

We'll be looking at front-of-house game wrappers later on. They include things like the title screen, instructions screen, pause screen, and win or lose screens, and are an essential part of your finished game. The best part is that if you build them well, you can reuse a lot of your work for every new game that you create!

Possible additional features: Sequel features for Motherload could include:

  • Switching between vehicle types

  • Mining on different planets

  • Managing multiple vehicles at the same time

  • A character mode where you get out and run around as a little guy, as in Blaster Master.

Alternatively, the sequel could just add new content: more ship upgrades, more ore types, and a larger play area, more story sequences, more sound effects and music tracks, and so on. This is what game reviewers can derisively call a MOTS (more-of-the-same) sequel. These days, you can get away with it by calling it an "expansion pack".

Note

Stretch your skills

Note

We're looking way down the road here, but if you create a sequel for your game, be sure to add at least one new feature. And, because you'll still be learning Unity, make sure that developing the new feature requires a skill that you don't already have. In this way, each game that you create will stretch your capabilities farther and wider, until you're an unstoppable Unity pro.

Heads up!

Pay close attention to a game's Head-up display (HUD). Video game HUDs contain graphical elements that usually don't make sense within the context of the game world, but they provide vital information to the player. A great example is the heart health meter in any Zelda game, or the energy bar in any fighting game. The Motherload HUD includes draining fuel and hull bars. It displays dynamic money and depth tallies. Three clickable elements lead the player to the Inventory, Options, and Instructions screens. Finally, a piece of text lets the player know that there are more shops to be found past the borders of the viewable game area.

Unity has great features for building game HUDs. Every HUD item type that you see in Motherload the graphical bar, the dynamic (changeable) text, the clickable icons, and the flashing helper text can all be built in the Unity game engine. Skip ahead to Chapter 4, Code Comfort if you're dying to try it!

Artillery Live!

Artillery Live! (http://www.gamebrew.com/game/artillery-live/play) is one of the many, many iterations of the classic artillery game mechanic, which is nearly as old as video games themselves. It was also built in Flash, but there's no reason it couldn't be built in Unity using 3D tank models and some awesome exploding particle effects.

The core mechanic: Artillery games share a familiar mechanic where the player sets the trajectory and power of his shot to demolish the enemy tanks. This version also has a wind speed feature that affects the way the tank shells travel through the air. Over time and in other incarnations, the game mechanic evolved into a pull-back-and-release experience, mimicking a slingshot. Other versions have the gun turret automatically angling towards the mouse, and the player holds down the mouse button to power up his shot.

The skin: The Gamebrew version is a classic tanks-and-mountains affair, holding true to the very first artillery games developed by game development pioneers in the 1970s. These games transformed from text-only titles to primitively illustrated games with pixelated tanks. An obvious alternate skin is to replace the tank with a man holding a bow and arrow (refer to the Bowman series of online games).

Among the more interesting artillery skins in recent memory are the Worms series, which replaces tanks with teams of anthropomorphic annelids bent on heavily armed destruction, and GunBound, an online multiplayer game where players pilot giant vehicles and mount into battle. In addition to tanks, GunBound throws animals and mythical creatures into the mix.

The feature set: In addition to the core mechanic, the front-of-house features, and computer-controlled players, the Gamebrew version of artillery offers turn-based multiplayer gameplay. Multiplayer games are a huge topic and deserve a book of their own. Unity does have features to enable multiplayer play. Unity interfaces nicely with out-of-the-box socket server solutions like SmartFoxServer or ElectroServer, or any server you decide to write on your own. But multiplayer is outside the scope of this book. If you've never programmed a multiplayer game before, you should know that they come with a universe of headaches all of their own! You're definitely better off tackling single-player games if you're just starting out.

The skinny on multiplayer: More and more gaming is moving from the lonely, isolated hobby of teenage boys in their moms' basements to a pastime that people enjoy in groups, either in person or virtually. Any time you move beyond a single-player experience, you're spending more time, money, and brain power to build the game. Here's a list of multiplayer features in order from the most expensive or difficult to least:

  • Multiplayer, different computers, real-time: Think of an action game like Quake where everyone's running around and shooting all at once. Real time is the most expensive to develop because you need to make sure all the computers "see" the same thing at once. What if the computer drops a connection or is slower than the rest?

  • Multiplayer, different computers, turn-based, synchronous: Boggle, Battleship, and various card and parlor games fit into this category. You don't have to worry about the computers constantly sending and receiving the right messages multiple times per second, so it's a little more forgiving.

  • Multiplayer, different computers, turn-based, asynchronous: Instead of people playing at the same time, their latest turn is sent via a Facebook message or an e-mail. Enabling players to grow old and die between moves really takes the messaging pressure off. The Scrabble-like Words With Friends is a great example.

  • Multiplayer, human versus computer: This is a costly option because you have to write code to make the computer player "intelligent" enough to defeat a human player. The difficulty in doing this changes depending on the type of game. It's easier to program artificial intelligence for a game like Connect Four than Chess.

  • Multiplayer, same computer, human versus human: This is the easiest to do. There's no complicated messaging going back and forth between computers, and you don't have to write artificial intelligence for a computer player. Regardless, it's still more effort to build than a strictly single-player game and it's dubious if people actually crowd around a single computer playing games in this way. (Devices like the iPad may make this style of play more likely.)

Possible additional features: The Worms series did a great job of iterating on the artillery concept by adding a slew of additional features:

  • Weapons inventories (including the standard issue bazooka, and the not-so-standard-issue Super Sheep and Holy Hand Grenade)

  • Limited or collectible ammo

  • Team-based play with turn time limits

  • Environmental extras such as land mines, oil barrels, and cargo drops

  • Moving and jumping

  • Physics-based platforming with the ninja rope

  • Cutscenes

  • Nameable characters

  • Single-player levels

  • Unlockable extras

The Worms series is an excellent example of how you can take a simple, fun mechanic, skin it creatively, and go nuts with a bevy of brilliant features. But, the most important thing is to start by building artillery, not Worms.

Note

Bang for your buck

By far, the Holy Grail of feature development is finding features that are fast and cheap to build, but that give players the most pleasure. Being able to name your team of worms provided untold entertainment. I remember spending a lot of time with one version of the game creating my own custom sound effects for the worms to say whenever they'd blow stuff up. It wasn't too tough a feature for the developers to build, and I almost spent more time customizing my team than I did playing the game!

Note

Build a game, buy a house?

If you think that players only notice the big ideas and the big games with hundreds of people working on them, artillery offers you a re-education! iPhone developer Ethan Nicholas released a version of artillery on the iPhone and, to date, has earned $600, 000 on his game. It's definitely possible to be small and successful.

Pong

Seriously, Pong? Yes, Pong. The British Academy of Film and Television Arts hosts an online version of the classic game (http://www.bafta.org/awards/video-games/play-pong-online,678,BA.html). The original Pong is credited with kickstarting the commercial video game industry that we know today.

The mechanic: Pong takes its name from ping pong a real-world activity where two players use paddles to bounce a ball at each other across a table with a tiny net. Ping pong was adapted from tennis, after people finally realized that all that running around was too much effort.

Some real-world activities lend themselves very well to video game mechanics. Not quite 50 years old, the video game industry is still very much in its infancy. There is an enormous wealth of fun stuff in the physical world (like playing ping pong or blowing up tanks) that's waiting to be adapted to a terrific video game mechanic. Are you clever enough to find one of those undiscovered mechanics and build the next Pong?

The skin: Like many early games, Pong obviously leaves a lot to be desired. Video game skins of tennis and ping pong have come a very long way, and can be radically diverse. Compare the ultra-realistic treatment of ping pong in Rockstar Games presents Table Tennis with the all-out insanity of Nintendo's Mario Tennis games, which add spinning stars and carnivorous plants to the playing field.

In both cases, be aware of the HUD elements. All three games Pong, Table Tennis, and Mario Power Tennis display a dynamic (changeable) piece of text on the screen to show score data. Table Tennis also has player names, an exertion meter, and little circles that display how many games each player has won. Look at the positioning of those elements. In all cases, and in our Motherload example, these HUD elements are displayed at the top of the screen.

The feature set: As Pong evolved, the feature set became far richer. Satisfied that the simple mechanic of hitting a virtual ball back and forth was enough to hang a game on, both Rockstar Games and Nintendo were able to blow out Pong with feature sets so juicy that the games' Pong origins were barely recognizable. By implementing tennis-style scoring, they made these games much more like tennis with very little effort. Both games add tournaments, rankings, and different player characters with varying skill sets. Mario Power Tennis adds about 30 new features involving mushrooms. Pong is a true testament to the level of complexity a simple, strong game mechanic can aspire to. But, again, if you want to make a fully-featured game like Table Tennis or Mario Power Tennis, the key is to start with a simple game like Pong.

The mechanic that launched a thousand games

The Pong game mechanic is so simple and so effective that its impact can be felt far and wide throughout the annals of video game history.

From Pong, we get Breakout. The iteration here is to turn Pong into a single-player game like real-world handball or squash, with the addition of a breakable brick wall. Breakout introduces stages or levels to the Pong concept, each with a different configuration of bricks.

Arkanoid iterates on Breakout by changing the skin to a sci-fi theme. The paddle becomes a spaceship. Arkanoid adds a few new features, most importantly power-ups that come in the form of capsules that are released when the ball smashes into the bricks. When the player catches the capsules with the spaceship, the game rules get bent. The spaceship can become longer. It can become sticky so that the player can catch the ball and plan the next shot. My favorite Arkanoid power-up is the red capsule marked "L"; it enables the spaceship to fire laser beams to destroy the bricks!

The Pong legacy brings us all the way to the present day, with Peggle by PopCap Games. Peggle combines a few different game mechanics: the brick-smashing and ball-bouncing of Breakout, the angular aiming of Bust-A-Move or Puzzle Bobble, and the random insanity of real-world pachinko games. To jazz up the skin, PopCap adds cartoon unicorns and gophers, and in one of the most talked-about payoffs in video game history, Peggle rewards players with an absolutely over-the-top slow-motion winning shot while blaring the climax of Beethoven's 9th Symphony!

Peggle teaches us some important lessons:

  • A few small twists on a timeless mechanic will still sell. Peggle has been downloaded over 50 million times!

  • Small games and large games can play nicely together. Famed MMORPG World of Warcraft (WoW) is embedded with a special version of Peggle, along with another blockbuster PopCap Games hit, Bejewelled. WoW players can use Peggle to decide how to distribute loot among the party members, which is probably more fun than flipping a coin.

  • You stand to reach a broader audience if you package your game with friendly, well-illustrated unicorns and gophers instead of dark and brooding axe-wielding superwarriors named "Kane" or "Glorg".

  • Music and sound play a crucial role in your design. They can make the game.

Have a go hero Redesign your favorite games

What if you were in charge of creating sequels to some very well-known games? Sequels to Pac-Man added 3D mazes, jumping, and a red bow to the main character's head. Is that what you would have done? Take a look at this list of popular games and think about which gameplay features you might add if you were in charge of the sequel:

  • Pac-Man

  • Tetris

  • Wolfenstein 3D

  • Wii Sports Boxing

  • Chess

  • Space Invaders

Toy or story

The approach that we're taking to your initial idea phase is not an approach that comes naturally. Usually, new game developers want to start with setting, story, and character, as if writing a book. That's how we've always been taught to begin a creative project. As there's often so much overlap between narrative forms like books, movies, and TV shows, it's tempting to start there. "My game is about a dark, brooding superwarrior named Kane Glorg who doesn't know who his parents are, so he travels the wasted landscape with his two-handed axe and his vicious battle sloth, slicing through hordes of evil slime demons in his ultimate quest to punch Satan in the face."

The take-away from this chapter is that all that stuff is window dressing. When you're just starting out - and unless you're building an explicitly narrative game like a graphic or textbased adventure - story, setting, or character will be the end point, not the start point. Too many would-be game developers get caught up in the epic implications of their story design instead of worrying about what's most important: does my game have a fun, simple mechanic that players will enjoy?

When you're designing a game, you're not creating a narrative. You're creating a toy, which can be wrapped like a sausage roll in flaky layers of delicious storytelling, character arcs, and twist endings, but you need to start with the toy. You need to start with that small, singular piece of joy that puts a smile on your player's face. As Shigeru Miyamoto, the man who created Mario, Donkey Kong, and Zelda, said in his 2007 keynote at the Game Developers Conference, start by imagining your player having fun with your game, and work backwards from there.

Note

Shopping for ideas

One great place to find inspiration for games is your local toy store. Ignore the toy skins, like the high-seas adventure of Lego Pirates sets, and focus on the mechanic: building. Ignore the giant fire-breathing scorpion head skin on that Hot Wheels track set, and think about the mechanic: the fun, physical way the little cars fly over the ramps. And be sure to investigate the small, simple toys in the end aisles, in the nickel bins, and inside those chocolate eggs and bags of caramel popcorn. You're bound to find game mechanic ideas there.

Pop Quiz Finding that singular piece of joy

What follows is a list of video games that are all based on a real-world physical game mechanic. In some cases, they're based on a physical game, and in other cases, they're based on goofing around. Can you identify the singular piece of joy from which these games take their cue? The answers are written on a folded piece of paper that I've hidden underneath your chair.

  • Super Monkey Ball: Tilt the level to guide a sphere along ramps, spirals, and treacherously thin platforms suspended above a bottomless void.

  • Metal Gear Solid: Hide behind crates and other pieces of cover while heavily armed guards seek you.

  • Boom Blox: Throw a ball at a stack of blocks that have different physical properties to knock them all down or to make them explode.

  • Katamari Damacy: Roll a ball around in random detritus scattered around the level and watch it grow ever larger. Roll up a writhing junk wad of sufficient size to reach the goal.

  • Dance Dance Revolution: Light up a series of scrolling arrows by stepping on their corresponding buttons on a flat input pad. The button presses are timed to the beat of a backing soundtrack.

Redefining the sky

The sky's the limit, and Unity starts us off with an endless sky. But, through this chapter, we've seen that that endless sky can actually trap us into an ambitious concept that we'll have no chance of completing. So, let's redefine the sky. Instead of wondering how big and complex your game can be, think about the endless array of simple interactions and moments of joy our world contains. Throwing and catching a ball, knocking a pile of stuff over, feeding an animal, growing a plant the world is packed with simple, effective interactions that ignite our most primitive, most basic Joy Cortexes, which is a neurological term that I've entirely invented just now.

If you want to discover one of these joy-producing real-world moments, study a child. Because games are all about play, the simple things that amuse and delight children and babies are the stuff of award-winning games. What is Metal Gear Solid if not a complex game of hide and seek? Rock Band and Guitar Hero are digital versions of all those times you played air guitar and pretended to be a rock star in front of the mirror with your bedroom door closed. Have you ever rolled snow into giant balls to build a snowman? Katamari Damacy is the video game expression of that joy-producing activity.

Summary

In case you ever need to answer a multiple-choice quiz on this chapter, here's a quick rundown of what we've learned:

  • Big game ideas are the enemy! Consider thinking small and building slowly to achieve big success.

  • By cutting features from your game ideas, you can whittle your design down to a more manageable size than by cutting content.

  • A game's mechanic is distinct from its skin. A single, strong game mechanic can support a myriad of different skins through a whole host of great games.

  • Start taking notice of the front-of-house aspects and HUDs in the games that you play. You'll be building your own a few chapters from now!

Let's begin

For the rest of this book, we're going to ignore the epic implications of that endless Big Sky Country 3D plane in the Unity Scene view. We're going to focus on small, simple, and fun game mechanics. Once you close the back cover of this book, you can take those simple concepts and iterate on them, even blowing them out to ambitious fully-featured crazy-fests like Master of Orion or Mario Power Tennis. But, stick to the strategy that will make you successful throughout start at zero, discover that singular piece of joy, and iterate until your game is finished.