CREATE COMPUTER GAMES – DESIGN AND BUILD YOUR OWN GAME
Published by: John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030-5774, www.wiley.com
Copyright © 2018 by John Wiley & Sons, Inc., Hoboken, New Jersey
Published simultaneously in Canada
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without the prior written permission of the Publisher. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions
.
Trademarks: Wiley, For Dummies, Dummies.com, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and may not be used without written permission. All other trademarks are the property of their respective owners. John Wiley & Sons, Inc. is not associated with any product or vendor mentioned in this book.
LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ.
For general information on our other products and services, please contact our Customer Care Department within the U.S. at 877-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002. For technical support, please visit https://hub.wiley.com/community/support/dummies
.
Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with standard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to media such as a CD or DVD that is not included in the version you purchased, you may download this material at http://booksupport.wiley.com
. For more information about Wiley products, visit www.wiley.com
.
Library of Congress Control Number: 2017959162
ISBN: 978-1-119-40418-7 (pbk); ISBN: 978-1-119-40422-4 (ebk); ISBN: 978-1-119-40424-8 (ebk)
This book explains the basics of game design using the free game development tool Unity. This book was created to make Unity accessible for young adults who are interested in the process of game design but don’t know where to begin.
Game design is tough. It involves figuring out and understanding everything from design to coding. Knowing where to begin is daunting and can feel inaccessible. Just keep in mind that no one starts off great at game design. You don’t need to know everything to start, and thinking that you do is one of the hardest challenges to overcome.
This book was written to get people like me to start thinking about game design in a different way. This book isn’t about making a perfect game or about teaching you everything about game development or even Unity. This book is a starting line. It teaches the basics and encourages you to think about games differently.
This book was written with the thought that games are tough to make and that coding is confusing. Think of this like a cookbook that explains why you use two eggs instead of three and what the pepper does to help bring out the flavor. The codes and game development that this book walks you through are approached from the bottom up. Things make sense when you understood why certain codes or components are needed. Just knowing the ingredients to a recipe doesn’t teach you how to cook.
This book was written for teenagers who have an interest in developing games. People who have spent years working in game design will find this book repetitive and probably not useful at all. I don’t pretend that this teaches everything about game design — I know for a fact that it doesn’t. This book is an introduction to the field, so it was made for people who have little to no idea where to even begin when they design their games. Some rudimentary typing skills and access to a computer and the Internet are all you really need to read this book. You’ll also need a copy of Unity, which you can download for free (I’ll show you how).
Throughout this book, I use the following icons:
Tips give some clarifications or offer shortcuts. I use tips to help you understand the program better or do things in an easier way.
Anything marked by the Remember icon reminds you of principles or ideas that you should think about throughout your game development.
This book takes you step by step through the process of designing a 3D platformer. If you have a clear idea of what game development is and know about Unity’s interface, you can skip the first two chapters and start with Chapter 3, where I dive into actually developing a game.
Chapters 8 through 10 use a separate program known as Blender and go into the basics of animation. If you aren’t interested in adding animation or you already have animations you want to include in your game, you can skip those chapters.
All the other chapters build off of each other and are designed to take you through the steps necessary for developing an example game that you’ll build with this book.
In this chapter, you’ll ask yourself questions about not just your games but all games. When you’re designing computer games, you need to think about the fundamental reasons people play games in the first place. The reasons people play strategy games aren’t the same reasons they play horror games. Both kinds of games are fun, but for very different reasons. The goal of this chapter is to help you understand what those reasons are so that the games you design deliver what your players are looking for.
Understanding how game mechanics and themes work together to create a gaming experience will help you better visualize and create your own game. If the mechanics aren’t fun or don’t fit, it doesn’t matter how cool the theme is — the game won’t be fun. If the theme doesn’t match the mechanics, the game might be fun but it won’t be memorable. If you aim to create great games, you need to understand both mechanics and themes before you even open the software you’ll use to build your games.
Have you ever played a game that you couldn’t put down? One that gave you the ability to shut off your mind without a care in the world because you were just hooked on it? A game that was just a lot of fun? I’m sure you have! Otherwise, you wouldn’t be reading this book.
But why were you sucked into the games you love? Why are they so addicting? What makes them fun?
Fun is where games live and die. If a game isn’t fun, nobody plays it. The first thing you have to understand, though, is that there are different types of fun, and different kinds of games:
And these are just a fraction of the types of games that are available to play. Like films, there are many different genres, some broad (like action games) or specific (like puzzle-based fighting games — look up Super Puzzle Fighter).
Whether it’s to feel accomplished after beating a challenging level, or to feel powerless as you wander through the woods while an unknown monster hunts you, you want a game to provoke some sort of emotion in you. Fun comes from a game provoking the right emotion at the right time.
If you think about it, this is the same reason you watch a movie or read a book. When you want to laugh, you watch a comedy. When you want to cry, you read a tragedy. Understanding that fun comes in many different forms and goes beyond a single emotion can open up a variety of game design that you may not have thought about before.
Think of game design like making something good to eat. You wouldn’t just throw any ingredient into a pan and hope for the best. To make it taste great, you need to start by asking yourself what kind of food you want to make. Are you making a salad? An appetizer? A soup or dessert? Once you know what the purpose of the food is — to be a satisfying entrée or a sweet treat at the end of a meal, for example — you can choose a recipe that will get you to your goal. And after you take it out of the oven or finish combining the ingredients, you might decorate it or add a garnish to make it look good.
Similarly, before you design a game, you need to ask yourself what type of game you want to make and who will be playing the game. In this section, I’ve listed some of the questions you should ask yourself.
Do you want to make a war game that puts players in the middle of World War II or a game about a haunted children’s restaurant where animatronic machines are trying to kill you? What your game is about can help you think about the story and help contextualize some of the decisions you’ll make as you’re designing your game.
Is your game a choice based role-playing game (RPG) or a more linear platformer? There are many different types of games that you can make. The type you choose can drastically change how people see your game.
Imagine if Skyrim were a 2D platformer, or if Five Nights at Freddy’s (shown in Figure 1-5) gave you the ability to move around. Imagine how different those games would be.
Do I want my player to feel powerful or powerless? A game that encourages exploration in a vast wasteland, like Fallout 4 (shown in Figure 1-6), provokes different feelings than a game that puts players in a cramped hallway. You want to go into your game knowing what type of feelings you want the player to feel. Knowing this can influence mechanic and story decisions.
Is he a soldier in the war fighting for his country, or is he the civilian just trying to survive as the war happens around him? When you make your game, think of how you want to frame your story or your characters. The story of a brave knight trying to vanquish her nemesis, the evil warlock, is far different than a story of an evil knight bent on defeating the good wizard.
Games have goals. Sometimes the goal is to defeat the villain. Other times, it’s to survive until morning. Think of your game as a story. Characters need a purpose. Mario isn’t just running around the mushroom kingdom for fun. He’s going to rescue the princess. Setting a clear objective for your player will give her direction in your game. Even games that focus on exploration set objectives that the player can strive for. Even if the objective isn’t the most important part of your game, it’s important to have one.
What is stopping your player from reaching his goal? Games aren’t fun without any challenge. You never want your player to be bored in your game. The easiest way to prevent boredom is to understand what types of obstacles the player needs to overcome. This can take the shape of enemy characters trying to kill your player or just puzzles that the player has to solve.
The most important question of all is who you’re designing your game for. The type of person who plays a peaceful game like Minecraft (shown in Figure 1-7) may not be the same type of person who plays a fast-paced fighting game like Street Fighter. Knowing the type of person you want to play your game can help determine the type of game you create.
A good exercise is to create a game on paper before you go into designing a game on the computer. This will help you understand the importance of mechanics in your game without your getting caught up with all the bells and whistles that come with a theme. Try thinking of a simple objective-based game that a person can play with just a pen and paper.
Unity is a program that you can download online for free — just go to www.unity3d.com/get-unity/download
. Developed by Unity Technologies, this open-source program has opened up game development for a whole new generation of game developers (like you!). You can use Unity to develop 2D and 3D games, but for the purposes of this book, I show you how to develop a 3D game.
In this chapter, you’ll learn some basic organization techniques that will help you manage your game creation. I show you how to create a new file in Unity, introduce you to the basic layouts and controls of Unity, and explain how to create an in-game object. This chapter may not be the most exciting, but you really need to understand these basics before beginning your game, so don’t skip ahead!
Similar to the games you play (and will create!), game making is modular. You have to take things one step at a time. In later chapters, you’ll dive into more difficult parts of game creation that have way more moving pieces and files to keep track of. Organizing your files and knowing the layout of Unity will save you the headache of trying to locate your files or tools, not to mention hours trying to retrace your steps.
Whether you’re baking cookies or changing the oil in your car or developing a computer game, you need to get organized first. Getting organized isn’t the fun part of any job, but it makes every job easier.
Unity does a lot of heavy lifting when it comes to organizing the files you need to create your computer game. But before you begin creating your game, you need to create a directory to store all your games in. This directory serves two purposes:
When you create games on your own, apart from this book, you can make these directories as specific or as broad as you want, to include things like music files, sound files, image files, and so on. For the purposes of the game you’re building in this book, the directory described here (shown in Figure 2-1) will serve you just fine.
When you have your directory set up (see the preceding section), you’re ready to create a new file. Follow these steps:
Click Create a New File.
The new project screen appears (see Figure 2-2).
In the Location field, enter Unity_Files.
That’s the folder you create in the preceding section.
Click Create Project.
A new folder is created within the Unity_Files
folder that contains all your game information, as well as all your assets (components that are used within the game, game objects, characters, music, images, and other types of files used in our game are all examples of assets).
When you open Unity, you’re greeted with a scary-looking screen (shown in Figure 2-3). Do not be scared of Unity. The best way to get over your natural fear is to understand what every part of the screen is and how it relates to the game you’re creating.
Here’s what you’re looking at in Figure 2-3:
Toolbar: The Toolbar (shown in greater detail in Figure 2-4) is located at the top of the screen. It gives you control over the scene, allowing you to transform the objects and move around the entire scene area. On the Toolbar, you find the controls for playing and pausing the game and accessing your account on the Unity cloud.
Here are the tools you find on the Toolbar:
Being able to navigate around your scene is important when you’re creating your game. You need to be able to move and rotate the scene controls in order to control and create your game. There are three main ways to do that:
When you know how to navigate around the scene, you’re ready to create and manipulate game objects.
There are two ways to create an object in Unity. You can either select the GameObject menu (near the File and Edit menus) or, under the Hierarchy tab, select the Create drop-down menu. Whichever method you use, choose 3D Object ⇒ Cube. That’s it! You’ve created a 3D game object!
Before you start playing around with the cube, reset the origin of the cube to be sure it’s at the center of the screen. To reset the origin of an object, follow these steps:
Click Reset.
The rotation and position are both reset to 0 and the scale is set to 1, centering and resetting the size of the object. This will help you better place and move around your objects in the scene. It also guarantees that all your objects remain at the same axis of rotation and exist in the same scale.
You know how the Toolbar can transform your objects, but there is another more precise way to do this in the Inspector window. The Transformation section of the Inspector window moves, scales, and rotates objects by specific numbers along the set axes:
Play around with these controls to get used them. Then set the Scale of the cube to 4 in the X, Y, and Z (the Position and Rotation should remain 0), as shown in Figure 2-6.
You’ve created a cube object, but there are other objects you can create in Unity. Here’s a brief overview: