Getting Started with Unity will get you up to speed with Unity3D's core features, using an easy step-by-step approach. Throughout this book, you will progressively develop your skills to create a survival video game.
From Unity3D's interface to finite state machines with Mecanim, you will learn all of the necessary features to create a great game, including built-in objects manipulation, collision detection, textures, scripting, audio, particle effects, pathfinding, and raycasting.
You will create an indoor environment, where the player can collect objects (including a gun, ammunitions, or health packs), shoot at enemies, open doors based on some conditions, and much more.
You will include animated zombies with different levels of intelligence that follow and attack the player based on a finite state machine and some AI techniques (for example, breadcrumbing).
You will also learn how to create a menu system for your game, manage and display the health levels of the character, and keep track of these factors across levels.
Chapter 1, Getting to know Unity3D, is a general introduction to Unity3D. In this chapter, we will look at Unity3D's interface and how to include assets to scenes, using both built-in objects and external files, such as sounds and textures. We will also become familiar with the most commonly used components in Unity3D.
Chapter 2, Creating a Maze with Built-in Objects, illustrates how to create a simple, (yet challenging) indoor environment using Unity3D's primitives and standard assets.
Chapter 3, Using Scripts to Interact with Objects, explains how to use scripting in Unity3D to create a user interface, handle user interaction, and display customized messages on the screen.
Chapter 4, Creating and Tracking Objects, explains how to add more interaction to our game with special effects, GUI elements, and a mini-map. We will also look at advanced techniques to handle cameras and camera views.
Chapter 5, Bringing Your Game to Life with AI and Animations, teaches you how to bring the game to life by animating objects and characters, and by giving NPCs some levels of artificial intelligence to challenge the player. We will also learn how to set up and manage a finite state machine with Mecanim to manage these characters.
Chapter 6, Finalizing and Optimizing Your Game, will introduce you to a technique called breadcrumbing to improve the NPCs' intelligence and pathfinding. You will also learn how to create menus for the different stages of the game, and how to navigate through them.
To complete the projects in this book, you only need Unity 4.x (or a more recent version) that you can download from www.unity3d.com/download/.
All instructions on how to download and install Unity3D are provided in the first chapter.
This book is for game developers who would like to learn how to use Unity3D and become familiar with its core features. This book is also suitable for intermediate users who would like to improve their skills. No prior knowledge of Unity3D is required.
In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.
Code words in text are shown as follows: "Create a new Boolean parameter called withinReach
."
A block of code is set as follows:
public var walking:boolean = false; public var anim:Animator; public var currentBaseState:AnimatorStateInfo; public var walkForwardState:int = Animator.StringToHash("Base Layer.WalkForward"); public var idleState:int = Animator.StringToHash("Base Layer.Idle"); private var playerTransform:Transform; private var hit:RaycastHit;
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
case:walkForwardState var zombies:GameObject [] = GameObject.FindGameObjectsWithTag("zombie"); for (var zombie:GameObject in zombies) { if (Vector3.Distance(transform.position, zombie.transform.position) < 8.0f) zombie.GetComponent(controlZombie).setWalking(true); } break;
New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Click on the Animations tab, and then click on the label attack; this label will provide information on the attack clip."
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply send an e-mail to <[email protected]>
, and mention the book title via the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]>
with a link to the suspected pirated material.
We appreciate your help in protecting our authors, and our ability to bring you valuable content.
You can contact us at <[email protected]>
if you are having a problem with any aspect of the book, and we will do our best to address it.