9,99 €
PUT DOWN YOUR CONTROLLER Why just play videogames when you can build your own game? Follow the steps in this book to learn a little about code, build a few graphics, and piece together a real game you can share with your friends. Who knows? What you learn here could help you become the next rock-star video- game designer. So set your controller aside and get ready to create! * Decipher the code - build some basic knowledge of how computer code drives videogames * Get animated - create simple graphics and learn how to put them in motion * Update a classic - put your knowledge together to put your modern twist on a classic game
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 310
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)
Cover
Introduction
About This Book
Foolish Assumptions
Icons Used in This Book
Where to Go from Here
Chapter 1: What Is Game Design?
Thinking about What Makes Fun Games Fun
Asking the Right Questions before You Begin
Creating Your Game on Paper
Chapter 2: Unity: The Software You’ll Use to Build Your Game
Getting Organized
Creating a New File
Understanding How Unity Is Laid Out
Navigating the Scene
Creating a Game Object
Creating and Using Prefabs
Chapter 3: Creating Level 1
Understanding the Importance of Level 1
Designing Your First Level
Creating the Gray-Box Level
Giving Your Level Objective and Direction
Chapter 4: Camera, Character, and Controls
The Three Cs of Game Development
Creating a Character Stand-In
Thinking about Code
Adding Rigidbody Component and Understanding Box Colliders
Coding Your Player
Coding Advanced Movement
Coding Pickup
Creating Tags and a User Interface
Coding Your Camera
Chapter 5: Making Your “Game” into a Game
Thinking About What a Game Is
Creating and Coding Your Obstacles
Creating Respawn Points
Coding Respawn Points
Chapter 6: Play Testing
Defining Play Testing
Knowing When to Start Play Testing
Deciding Who Should Play Test Your Game
Knowing What to Look For
Handling Feedback
Finding the Problems in Your Game
Chapter 7: Fixing and Adjusting Your Game
Turning Criticism into Construction
Punishing Your Player Less
Creating a User Interface Tutorial
Preventing Wall Climbing with Raytracing
Chapter 8: Animating in Blender
Mixing Things Up with Blender
Downloading Blender
Opening Blender for the First Time
Creating a New File in Blender
Figuring Out the Blender Interface
Navigating the Interface
Editing Your Object
Chapter 9: Creating Your Assets
Thinking about Theme and Style
Creating Your First Character
Creating the Enemy Grunt
Creating an Environmental Hazard
Creating the Moving Platform
Creating the Coin Pickups
Customizing on Your Own
Chapter 10: Animating Your Characters
Defining Animation
Learning Animation
Animating Your Player Character
Animating the Enemy Grunt
Animating the Environmental Hazard
Animating a Moving Platform
Animating the Coins
Chapter 11: Coloring and Lighting Your Game Level
Changing the Ground Color
Editing the Environmental Lighting
Understanding Lighting
Creating Fog
Chapter 12: Importing Your Characters into Your Game
Fixing Your Player Character for Importing into Unity
Importing Your Player Character into Unity
Importing the Other Characters and Objects
Chapter 13: Play Testing (Again)
Testing the Second Time
Fixing Your Game
Wrapping Up the Noticeable Issues
Chapter 14: Finalizing Your Game
Creating Multiple Levels
Resetting the Level
Exporting Your Game
Continuing Your Game Design
About the Author
End User License Agreement
Cover
Table of Contents
Begin Reading
i
ii
iii
iv
v
vi
vii
ix
x
1
2
3
4
5
6
7
9
10
11
12
13
14
15
16
17
18
19
20
21
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
245
246
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:
Fighting games
reward quick thinking and reading your opponent’s moves and figuring out the proper combo to counter it with.
Strategy games
(like XCOM 2, shown in
Figure 1-1
) challenge you to think and plan for a variety of situations, sometimes in an instant.
Adventure games
push you to explore and discover more about the world around you.
Horror games
(like Slender: The Arrival, shown in
Figure 1-2
) get your adrenaline pumping and push your natural curiosity to its limits.
Puzzle games
reward you for solving different complex puzzles and for problem solving.
Platformers
(like Super Meat Boy, shown in
Figure 1-3
) work off of reward and punishment and challenge you to master the controls and the timing to perfectly execute a level.
FIGURE 1-1: XCOM 2.
FIGURE 1-2: Slender: The Arrival.
FIGURE 1-3: Super Meat Boy.
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.
When you’re designing your game, ask yourself what type of emotion your game is trying to provoke — and capitalize on it! Sometimes that feeling is the excitement you feel in the heat of a battle. Other times, it’s the sadness you feel after a game forces you to question your own mortality and life choices, like in one of my favorite games, To the Moon (see Figure 1-4).
FIGURE 1-4: To the Moon.
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.
You don’t have to answer these questions in this order. Often in game design, you start by answering any one of these questions and build out from there. There is no right or wrong order to answer these questions, but you should answer all of them before you start designing your game.
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.
FIGURE 1-5: Five Nights at Freddy’s.
Mechanics complement story. Whatever type of game you aim to make, keep in mind how different mechanics can change the audience for the game.
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.
No matter what, the player will feel something when she plays your game. And one way to ensure that she isn’t bored when she’s supposed to be excited is to make the game with the type of feeling in mind you aim to provoke.
FIGURE 1-6: Fallout 4.
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.
FIGURE 1-7: Minecraft.
If you’re ever in doubt about who your player base is, ask yourself if you would want to play the game you’re making. Don’t design the game you think people want to play. Design the game you want to play.
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.
Paper games are tough because you need to get the player interested in the game without the fluff or theme. But in the end, if a game isn’t fun, a theme — no matter how cool — won’t fix it. Themes are important, but if you don’t have an interesting game without the theme, no one will want to play it.
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:
It creates an easy-to-remember spot on your computer for you to find all your files.
The last thing you want to have to do is dig around through a bunch of folders looking for where you saved your game.
Creating backups and transferring your files is much easier when they’re all in the same spot.
You don’t want some files in one place and other files in another. All your files for your games should be in the same area. Think of it the way you think of the notebooks you keep for your classes. You wouldn’t put your biology notes in your English notebook and that history quiz in your French folder — at least not if you want to pass those classes! The same goes for the files you use to build your computer games.
Computers are stupid — they can’t find files if you move them. To save yourself a ton of time and frustration, store all your files in one location.
Every time you start to create a new game, make a simple directory to store your files in. Unity automatically creates simple directories for your files, but for the purposes of the game you’ll be making in this book, you also need a directory that will include files outside the ones that Unity uses. To create a directory, follow these steps:
Create a folder calledUnity_Gamesin theMy Documentsfolder on your computer.Inside theUnity_Gamesfolder, create a folder calledBoxo_3D_Platformer.Inside theBoxo_3D_Platformerfolder, create two folders calledBlender_FilesandUnity_Files.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.
FIGURE 2-1: The directory for your new game.
When you have your directory set up (see the preceding section), you’re ready to create a new file. Follow these steps:
Open Unity.
Click Create a New File.
The new project screen appears (see Figure 2-2).
In the Project Name field, enter
Boxo_3D_Platformer
.
In the Location field, enter Unity_Files.
That’s the folder you create in the preceding section.
Select the 3D button.
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).
FIGURE 2-2: The New Project screen.
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.
FIGURE 2-3: This is what you see when you open Unity.
Here’s what you’re looking at in Figure 2-3:
Scene window:
The Scene window, one of the two main windows in Unity, is where you place and set up your game objects.
Game objects include everything that helps visualize your game. This includes objects that the player sees within the game, such as 3D objects and game text, as well as aspects of the scene that help bring the scene to life, such as lights and cameras.
Game window:
The Game window, the other main window in Unity, gives you a sense of how your game will look like when you finish. It’s a preview that lets you see what adjustments you need to make.
Project window:
The Project window allows you to manage the assets of your project. It organizes files by type. In the upper-right corner of the Project window, you can search for specific assets. Later on, the Project window will allow you to access your materials, scenes, prefabs, scripts, and other assets.
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:
Pan tool:
Grabs onto the screen itself and moves the camera to have a better view of the game objects or world.
Translation tool:
Moves your objects along the three axes of 3D (X, Y, and Z).
Rotation tool:
Rotates objects around the three axes.
Scale tool:
Allows you to adjust the size of your object, making it bigger or smaller along the three axes. The square around the dot is also a scale tool, but it scales from the corners of the object, as opposed to just the center or pivot point.
Gizmo tool:
Adjusts where the
pivot point
(the point that your object rotates or scales from) is on the object, as well as what direction of the axes you follow.
Your object will be rotated and moved a lot throughout this and other projects. Understanding the differences between local and global rotations will help you better control your scene. The global axes never change and remain in a fixed direction onscreen, no matter where or in what direction the object is. The local axes are attached to the object itself and change to match the angle the object is facing.
Play button:
Starts the game, along with any physics or events that start when the game starts. Pressing the Play button again resets the game back to the start.
Pause button:
Pauses the game during play.
Step button:
Moves the scene frame by frame after playing.
Cloud button:
Allows you to access Unity’s cloud-based services (see the nearby sidebar).
Account drop-down menu:
Allows you to access your Unity account online.
Layer drop-down menu:
Allows you to change which layers or objects are visible in the scene.
Layout drop-down menu:
Allows you to change Unity’s overall layout to better suit your style.
For the purposes of this book, keep the Layout drop-down menu set to 2 by 3.
Inspector window:
The Inspector window allows you to examine and alter the properties of selected objects. These properties change from object to object, so the Inspector window’s layout changes the most throughout your work, but knowing how to work in this window is vital to creating games.
Hierarchy:
The Hierarchy lists all the game objects in the scene and how they relate to each other. You can use the Scene window to select these objects or select them through the Hierarchy. Think of the Hierarchy as a list of all the things within your project.
Console window:
The Console window is at the very bottom of Unity’s screen. Its main purpose is to show you messages directly from Unity. Typically, what you’ll see here are error messages, often having to do directly with the code of the project. The Console window is most useful when you’re coding your game because it helps you narrow down what parts of your game are not functioning and why.
FIGURE 2-4: The Toolbar.
One of Unity's main selling points is its large community and greater opportunities for independent developers to find their way in the field of game development. Unity’s cloud services go a long way toward connecting the community together by offering:
Easy ways to back up your files for a detailed histories of your game’s progressA place to share your work and get constructive feedbackA way to connect and share work with other like-minded developers and collaborate on projects that update regularlyBeing 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:
Panning:
Panning moves up–down or left–right in the scene. If you’re using a mouse, you pan by clicking and holding the middle mouse button (the wheel in the middle of the mouse). If you’re using a trackpad on a Mac, you pan by clicking and dragging while holding the Alt and Command keys.
Rotating:
Rotating moves you around the scene as if you’re standing in one place and turning around to see everything around you. You rotate by holding down the Alt key and clicking and dragging on the scene.
Zooming:
Zooming moves you closer or farther away from the scene. If you’re using a mouse, you zoom by rolling the middle mouse button. If you’re using a trackpad on a Mac, you can zoom by using two fingers and sliding them up and down on your trackpad.
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:
Select the object whose origin you want to reset.
Go to the Inspector window for the object (see
Figure
2-5
).
From the Transform menu of the Inspector window, select the gear icon at the upper right.
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.
FIGURE 2-5: The Inspector window.
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:
Position
indicates where the box is in relation to the center point of the scene’s grid.
Rotation
indicates the angle that the box is in relation to each axis.
Scale
indicates the scale of the box in relation to its original size.
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.
FIGURE 2-6: Object Reset at 0,0,4.
You’ve created a cube object, but there are other objects you can create in Unity. Here’s a brief overview:
3D objects:
These are the normal game objects within 3D games. The 3D objects include the following:
Cube
Sphere
Capsule
Cylinder
Plane (flat surface)
Quad (a single face with four sides)
Rag-doll (a character)
Terrain
Tree
Wind Zone
3D Text
2D objects:
There is only one type of 2D object that you can create with this menu: sprites. Sprites are images that you can program to change to show different things for different actions — everything from a character running to a character shooting a gun or talking.
Empties:
Empties are invisible objects that you place in the scene to control or mark something about the scene. They won’t show up when you export your game and act only as controls within your game.
Lights:
Lights brighten the scene and can change how the game looks depending on the light setup. Lights are mainly used to brighten the characters and setting and help render a character in 3D.
Audio and video:
The Audio and Video menus help render videos and sounds into your game. These can range from background noise/scenes to music and dialogue.
UI:
UI
stands for
user interface.
This alters what the player sees onscreen while playing the game. It can range from text informing the player of the controls to images and health bars.
Particle systems:
Particle systems include a variety of different effects that can be seen onscreen, ranging from downpouring water to explosive fire blasts.
Cameras:
Cameras act as the player’s eyes into the game. They can be stationary or follow the player around, but their primary purpose is to frame how a game is played. This may not seem important, but the angle at which a game is played can change a lot about the game itself. One example: A first-person shooter framed as a top-down shooter is a vastly different play experience even if the controls are exactly the same.