1. Trang chủ
  2. » Công Nghệ Thông Tin

Unity for absolute beginners

598 192 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

TECHNOLOGY IN ACTION™ Unity for Absolute Beginners GET ON THE FAST TRACK TO BECOMING A GAME DEVELOPER WHILE LEARNING UNITY IN A FUN AND INTERACTIVE ENVIRONMENT Sue Blackman www.it-ebooks.info For your convenience Apress has placed some of the front matter material after the index Please use the Bookmarks and Contents at a Glance links to access them www.it-ebooks.info Contents at a Glance About the Author���������������������������������������������������������������������������������������������������������������xiii About the Contributor��������������������������������������������������������������������������������������������������������� xv About the Technical Reviewer������������������������������������������������������������������������������������������ xvii Acknowledgments������������������������������������������������������������������������������������������������������������� xix Introduction����������������������������������������������������������������������������������������������������������������������� xxi ■■Chapter 1: The Unity Editor������������������������������������������������������������������������������������������������1 ■■Chapter 2: Unity Basics���������������������������������������������������������������������������������������������������39 ■■Chapter 3: Scene Navigation and Physics���������������������������������������������������������������������103 ■■Chapter 4: Importing Static Assets�������������������������������������������������������������������������������153 ■■Chapter 5: Introduction to Scripting with C#�����������������������������������������������������������������197 ■■Chapter 6: Mecanim and Animation������������������������������������������������������������������������������243 ■■Chapter 7: Populating the Game Environment���������������������������������������������������������������291 ■■Chapter 8: Weaponry and Special Effects���������������������������������������������������������������������339 ■■Chapter 9: Incorporating Unity 2D���������������������������������������������������������������������������������389 ■■Chapter 10: Menus and Levels��������������������������������������������������������������������������������������447 v www.it-ebooks.info vi Contents at a Glance ■■Chapter 11: Bonus Features������������������������������������������������������������������������������������������525 ■■Appendix A: Rigging with Mixamo��������������������������������������������������������������������������������565 Index���������������������������������������������������������������������������������������������������������������������������������575 www.it-ebooks.info Introduction The Unity community is very large and very helpful There are videos, code, and 3D assets available on any number of topics, and the Unity help documents have recently undergone a major update But if you are new to any or all of the components of game development (scripting, 2D or 3D art asset creation and manipulation, or game design in general), you have probably discovered how overwhelming it is to make sense of it all One of the biggest challenges is to learn how to bring it all together Unlike short topic videos, this book takes you through the process of creating a game that seems very simple at first glance, yet becomes more sophisticated as you work your way through the design and creation process One of the great advantages books have over videos is the luxury to spend time on explanations In game development, there are always several different ways to solve design and technical problems, but there is rarely a “best” solution And unlike a large studio, where budget and time constraints dictate a highly detailed game document, you will discover that the game design and creation process must be flexible in order to be able to finish a game or even a working prototype About the Unity Game Engine Unity provides an excellent entry point into game development, balancing features and functionality with price point The free version of Unity allows people to experiment, learn, develop, and sell games before committing any of their hard-earned cash Unity’s very affordable, feature-packed Pro version is royalty free, allowing people to make and sell games with the very low overhead essential to the casual games market With its huge user community, Unity removes the elitist separation between programmers, artists, and game designers that is typical of high-priced game engines It makes it possible for anyone to take the first step to bringing their ideas to life In this book, you will get to wear many hats as you create your first Unity game, discovering where your interests lie as well as gaining an understanding of what is required should you reach the point where collaboration becomes appealing xxi www.it-ebooks.info xxii Introduction Will I Have to Learn to Script? You don’t have to be a programmer to make your own game with Unity, but you will need to be able to understand enough of what the scripts to know what can be tweaked to your advantage or decide if a particular script will suit your needs Most game play needs to be scripted in Unity, but there are hundreds of scripts already available that can be readily reused Unity ships with several of the most useful More can be found by searching the forum, Wiki, or UnityAnswers Many forum members will even write bits of script for less adept users In the Collaboration section of the forum, you can even find scripters looking to trade for art assets By the end of this book, you should know enough to be able to take advantage of the wealth of material available from the Unity community Games, by their very definition, are about interaction; even with games that are largely controlled by physics, logic-driven cause and effect is what differentiates games from linear, plot-driven passive media Even the most “artist friendly” game engines need scripting to move beyond simple environmental walkthroughs If you have no previous scripting experience, you will find that this book’s aim is to familiarize you with scripting a few lines at a time, while providing visual feedback as often as possible If you find you enjoy the scripting part of the project, feel free to delve deeper into programming with a more conventional approach What About Math? One of the most common things heard in the game industry by artists and programmers alike is, “If I’d known math was going to be so useful, I would have paid more attention in class.” Although it helps to have a good background in math, there are plenty of resources for both code and mathematical functions to help you solve a particular problem And, as always, there are plenty of people on the Unity Forum and Answers who may be willing to help as long as you can show that you have spent a reasonable amount of time trying to solve it yourself Assumptions and Prerequisites This book assumes that you are new to scripting, 3D and game design, and/or the Unity engine What This Book Doesn’t Cover This book is not about conventional game design; it is more of a precursor, getting you into the habit of analyzing needs and weighing choices Not only is creating a massive design document intimidating when you are the one who will have to implement everything, but it is likely to be unrealistic until you are more familiar with the engine and your own capabilities More typically, you will find yourself building your game up a little bit at a time, prototyping ideas and functionality as you go along This is not a book on how to become a programmer It uses programming best practices when possible, but the scripting in this book is designed to ease a non-programmer into the process by providing instant visual feedback as often as possible While there are usually several ways to attain the same goal, the scripting choices made in this book are generally the easiest to read and understand from an artist’s or designer’s point of view In this book, scripting is presented in the www.it-ebooks.info Introduction xxiii way a native speaker learns his own language He is surrounded by it, immersed in it, and allowed to tinker with it to slowly gain a basic working knowledge of it Don’t worry about remembering it all Some things you will use throughout the project, and others you will be encouraged to take note of for future reference Conventions Used in This Book Instructions look like this.What Is the General Structure of this Book? Tip  Follow this format Code looks like this Platform This book was written using Unity 4.5 in a Windows environment Differences for shortcut keys and operating system file storage with Unity on a Mac are noted throughout the book www.it-ebooks.info Chapter The Unity Editor The most exciting part of learning a new application is getting it installed and firing it up for the first time Following that, the most frustrating part can be the process of becoming familiar with its editing environment Unity is no exception, especially if you are already familiar with DCC (digital content creation) applications In this chapter, you will be introduced to the Unity editor and many of its key concepts As this will serve as a light overview for the rest of the book, don’t stress over trying to remember it all Installing Unity The first order of business is to download and install Unity if you have not already done so Unity has two license types: free and Pro When you download and install Unity for the first time, you will have the option of using a free 30-day trial of the Pro version It can be selected as a third option right in the license dialog upon installing Unity or upon returning the currently active license (an option that allows you to move Pro licenses to different machines) With a few exceptions, most of the Pro features are aimed at the optimization of your projects and are beyond the scope of this book If you are considering the purchase of Unity Pro, you should be aware that, with the exception of Windows Mobile, it will require a separate license for each of the mobile target platforms you wish to author for Unity User Account Currently, after you download and install Unity, if you don’t already have one, you will be required to create a Unity user account during the installation Your user account will provide access to the downloads, Unity Forum, Unity Answers, and the Unity Asset Store The forum provides a place for discussion of all things Unity Answers is where you can go to get quick solutions to your queries, and the Unity Asset Store is where you can find assets of all kinds (3D models, animated characters, textures, scripts, complete game environments, etc.) to help you with your project Once Unity is installed, you will find a direct link to each of these resources through the editor www.it-ebooks.info CHAPTER 1: The Unity Editor To get started, go to www.unity3d.com/unity/download With the account created, you can download Unity for Windows or Mac The download site will automatically offer the version that matches the platform you are currently on Installing This book was written using Unity 4.5 Because Unity regularly makes changes that can affect your projects, you may wish to use the 4.5 version even if the current version is newer If you prefer, you can install multiple versions of Unity on the same machine, providing you name the folders accordingly (e.g., Unity 4.5, Unity 4.6) You may only run one instance of Unity at a time, regardless of the version If you choose to have multiple versions, you will be required to start Unity from the desired version rather than from the desktop icon or the project itself, as the previously run version will open by default If that sounds like too much trouble, you can always check the book’s thread on the Unity Teaching forum, http://forum.unity3d.com/forums/23-Teaching, where both errata and version-change solutions will be posted and updated as necessary A search for the book’s title will help you find its thread Install Unity, following the prompts, including the sample project On a Windows machine, it will be installed in the Program Files x86 folder Upon the release of Unity 5.0, when it will be fully 64 bit, it should install itself in the regular Program Files folder The sample project will be installed in Documents ➤ Public Documents ➤ Unity Projects On a Mac, you will find it in /Users/Shared/Unity At this point, you should now see the Unity icon on your desktop (Figure 1-1) Figure 1-1.  The Unity application icon on the desktop Click the icon to open Unity If you downloaded the sample project, Unity will open with it already loaded (Figure 1-2) www.it-ebooks.info CHAPTER 1: The Unity Editor Figure 1-2.  The Unity sample project loaded If the Scene window is blank, you can double-click the Unity icon in the Assets folder to load the AngryBots scene The demo scene Unity ships with changes occasionally, so yours may be different Tip  When opening Unity from the desktop icon, it will open the previously opened project, provided it can be found If you did not choose to install the sample project, you will see the Project Wizard (Figure 1-3) www.it-ebooks.info 582 Index Unity editor (cont.) Hierarchy view, 19 Inspector view, 34 installation, layout options, 34 Preferences section, project structure file structure, 36 load/save, 38 project management, 37 project view Asset Store, 32 column layouts, 33 Favorites options, 31 Project Wizard, scene view 2D toggle, 24 Alpha option, 21 display options, 20 Effects drop-down menu, 25 Gizmos drop-down menu, 27 lighting off and on, 24 Main Camera, 15 Mipmaps option, 23 navigation, 14 Overdraw option, 22 RGB options, 21 Scene Gizmo, 16 Sound Effects toggle, 25 UI dark theme, Game view, 6–7 Hierarchy view, Inspector view, light theme, scene view, 6–7 user account creation, Windows menu, 11 UnityScript, 197 UpdateBattery( ), 510 UV Animator Script creation anisotropic filter, 558 BatteryHealth script, 562 bump texture offset, 557 FixedUpdate function, 557 Ignore Raycast layer, 559 Invader, 560 issues, 559 laser controller, 563 last-ditch attempt, 562 particle system, 560 SetTextureOffset method, 557 slug power-up, 562 Start function, 556 unity shaders, 557 x Offset value, 556 zombie bunnies, 561 zombie-bunny hit, 559 ■■V Variables booleans, 201 console, 206 definition, 200 error message, 206 exposed the inspector, 203 numbers, 200 rules, 200 script’s class declaration, 201–202 StoneGardenBench object, 203 strings, 201 unity-specific cabbage gameObject, 210 game object, 209 vs usual types, 209 unity’s scripting reference base class, 213 camera component, 213 Collider2D component, 213 C# specification, 211 dot notation, 213 gameObject, matches for, 212 gameObject vs Camera, 214 local machine’s installation, 210 myCustomScript, 214–215 namespace, 213 transform component, 210 view parameter, 214 www.it-ebooks.info Index ■■W, X, Y Weaponry, 339 advanced weaponary, 382 Collision type parameters, 382 OnCollisionEnter function, 382 OverlapSphere( ) function, 383 ReceivedHits script, 384 Terminator function, 385 particle systems (see Particle systems) post-processing effects, 385 projectiles, 339 Ammo tag, 348 C# script, 343 DestroyBun function, 349 Fire Point position, 341 Game Manager object, 349 launcher script, 340 OnCollisionEnter function, 344 PotatoAmmo, 345 potato assets, 344 potato gun range, 347 PotatoLauncher script, 342 ReceivedHit script, 351 scripting, 342 SendMessage function, 350 TransformDirection( ), 340 without gravity, 347 Writing scripts comments creation, 215 definition, 200 functions, 200 (see also Functions) variables, 200 (see also Variables) ■■Z ZombieBunny animator controller, 256 asset, 252 avatar, 255 Bunny Eat state, 257 clip parameters, 254 legacy animation, 253 Macanim state machine, 257 Root node, 253 set up, 252 Skinned Mesh Renderer component, 258 Zombie-bunny locator creation Spy Map, 528 Camera Spy View, 525, 528, 531–532 clipping plane, 527 Gnomatic Garden Defender, 530–531 GUI, 527 layer to control creation, 530 parameters, 526 particle system, 529 prefab, ZB Spot, 529 www.it-ebooks.info 583 Unity for Absolute Beginners Sue Blackman www.it-ebooks.info Unity for Absolute Beginners Copyright © 2014 by Sue Blackman This work is subject to copyright All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed Exempted from this legal reservation are brief excerpts in connection with reviews or scholarly analysis or material supplied specifically for the purpose of being entered and executed on a computer system, for exclusive use by the purchaser of the work Duplication of this publication or parts thereof is permitted only under the provisions of the Copyright Law of the Publisher’s location, in its current version, and permission for use must always be obtained from Springer Permissions for use may be obtained through RightsLink at the Copyright Clearance Center Violations are liable to prosecution under the respective Copyright Law ISBN-13 (pbk): 978-1-4302-6779-9 ISBN-13 (electronic): 978-1-4302-6778-2 Trademarked names, logos, and images may appear in this book Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made The publisher makes no warranty, express or implied, with respect to the material contained herein President and Publisher: Heinz Weinheimer Lead Editor: Michelle Lowman Development Editor: Douglas Pundick Technical Reviewer: Marc Schäerer Editorial Board: Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Louise Corrigan, Jim DeWolf, Jonathan Gennick, Jonathan Hassell, Robert Hutchinson, Michelle Lowman, James Markham, Matthew Moodie, Jeff Olson, Jeffrey Pepper, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft, Gwenan Spearing, Matt Wade, Steve Weiss Coordinating Editor: Kevin Shea Copy Editor: Roger LeBlanc Compositor: SPi Global Indexer: SPi Global Artist: SPi Global Cover Designer: Anna Ishchenko Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013 Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc) SSBM Finance Inc is a Delaware corporation For information on translations, please e-mail rights@apress.com, or visit www.apress.com Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use eBook versions and licenses are also available for most titles For more information, reference our Special Bulk Sales–eBook Licensing web page at www.apress.com/bulk-sales Any source code or other supplementary materials referenced by the author in this text is available to readers at www.apress.com For detailed information about how to locate your book’s source code, go to www.apress.com/source-code/ www.it-ebooks.info For my Mom, who is now finishing her first book www.it-ebooks.info Contents About the Author���������������������������������������������������������������������������������������������������������������xiii About the Contributor��������������������������������������������������������������������������������������������������������� xv About the Technical Reviewer������������������������������������������������������������������������������������������ xvii Acknowledgments������������������������������������������������������������������������������������������������������������� xix Introduction����������������������������������������������������������������������������������������������������������������������� xxi ■■Chapter 1: The Unity Editor������������������������������������������������������������������������������������������������1 Installing Unity ������������������������������������������������������������������������������������������������������������������������������1 Unity User Account������������������������������������������������������������������������������������������������������������������������������������������������ Installing���������������������������������������������������������������������������������������������������������������������������������������������������������������� General Layout������������������������������������������������������������������������������������������������������������������������������5 Menus�������������������������������������������������������������������������������������������������������������������������������������������������������������������� Getting Started���������������������������������������������������������������������������������������������������������������������������������������������������� 12 Exploring the Views��������������������������������������������������������������������������������������������������������������������������������������������� 19 Hierarchy View����������������������������������������������������������������������������������������������������������������������������������������������������� 19 Scene View���������������������������������������������������������������������������������������������������������������������������������������������������������� 20 Game View����������������������������������������������������������������������������������������������������������������������������������������������������������� 28 Project View��������������������������������������������������������������������������������������������������������������������������������������������������������� 31 The Inspector������������������������������������������������������������������������������������������������������������������������������������������������������� 34 Layout������������������������������������������������������������������������������������������������������������������������������������������34 vii www.it-ebooks.info viii Contents Project Structure�������������������������������������������������������������������������������������������������������������������������36 File Structure������������������������������������������������������������������������������������������������������������������������������������������������������� 36 Project Management������������������������������������������������������������������������������������������������������������������������������������������� 37 Load/Save������������������������������������������������������������������������������������������������������������������������������������������������������������ 38 Summary�������������������������������������������������������������������������������������������������������������������������������������38 ■■Chapter 2: Unity Basics���������������������������������������������������������������������������������������������������39 Unity GameObjects����������������������������������������������������������������������������������������������������������������������39 Creating Primitives���������������������������������������������������������������������������������������������������������������������������������������������� 39 Transforms����������������������������������������������������������������������������������������������������������������������������������������������������������� 41 Duplicating GameObjects������������������������������������������������������������������������������������������������������������������������������������ 47 Arranging GameObjects��������������������������������������������������������������������������������������������������������������������������������������� 48 Parenting������������������������������������������������������������������������������������������������������������������������������������������������������������� 49 Components��������������������������������������������������������������������������������������������������������������������������������������������������������� 52 Creating Environments ���������������������������������������������������������������������������������������������������������������56 Designing Smart�������������������������������������������������������������������������������������������������������������������������������������������������� 56 Creating Terrain��������������������������������������������������������������������������������������������������������������������������������������������������� 57 Populating the Terrain������������������������������������������������������������������������������������������������������������������������������������������ 75 Environment�������������������������������������������������������������������������������������������������������������������������������������������������������� 95 Shadows�������������������������������������������������������������������������������������������������������������������������������������������������������������� 97 Summary�����������������������������������������������������������������������������������������������������������������������������������101 ■■Chapter 3: Scene Navigation and Physics���������������������������������������������������������������������103 Scene Navigation����������������������������������������������������������������������������������������������������������������������103 First Person Controller��������������������������������������������������������������������������������������������������������������������������������������� 103 Colliders������������������������������������������������������������������������������������������������������������������������������������������������������������� 118 Physics��������������������������������������������������������������������������������������������������������������������������������������123 Rigidbody����������������������������������������������������������������������������������������������������������������������������������������������������������� 123 Cloth������������������������������������������������������������������������������������������������������������������������������������������������������������������ 137 Interacting with the First Person Controller������������������������������������������������������������������������������������������������������� 143 First Build����������������������������������������������������������������������������������������������������������������������������������145 Summary�����������������������������������������������������������������������������������������������������������������������������������151 www.it-ebooks.info Contents ix ■■Chapter 4: Importing Static Assets�������������������������������������������������������������������������������153 Supported Formats��������������������������������������������������������������������������������������������������������������������153 3D Assets����������������������������������������������������������������������������������������������������������������������������������������������������������� 153 Textures������������������������������������������������������������������������������������������������������������������������������������������������������������� 154 Audio����������������������������������������������������������������������������������������������������������������������������������������������������������������� 155 The Importer������������������������������������������������������������������������������������������������������������������������������155 Importing Assets into Your Project��������������������������������������������������������������������������������������������������������������������� 156 Asset Optimization��������������������������������������������������������������������������������������������������������������������������������������������� 166 Improving Generated Materials�������������������������������������������������������������������������������������������������178 Shaders������������������������������������������������������������������������������������������������������������������������������������������������������������� 178 Creating Prefabs������������������������������������������������������������������������������������������������������������������������190 Unity’s Asset Store��������������������������������������������������������������������������������������������������������������������192 The Asset Acquisition Process��������������������������������������������������������������������������������������������������������������������������� 193 Summary�����������������������������������������������������������������������������������������������������������������������������������196 ■■Chapter 5: Introduction to Scripting with C#�����������������������������������������������������������������197 Scripting for Unity���������������������������������������������������������������������������������������������������������������������197 The Script Editor������������������������������������������������������������������������������������������������������������������������198 Writing Scripts���������������������������������������������������������������������������������������������������������������������������200 Introducing Variables����������������������������������������������������������������������������������������������������������������������������������������� 200 Creating Comments������������������������������������������������������������������������������������������������������������������������������������������� 215 Exploring Functions������������������������������������������������������������������������������������������������������������������������������������������� 217 Summary�����������������������������������������������������������������������������������������������������������������������������������240 ■■Chapter 6: Mecanim and Animation������������������������������������������������������������������������������243 The Story�����������������������������������������������������������������������������������������������������������������������������������243 Importing Animated Assets�������������������������������������������������������������������������������������������������������243 Legacy Animation����������������������������������������������������������������������������������������������������������������������244 Adding Audio�����������������������������������������������������������������������������������������������������������������������������250 Mecanim�����������������������������������������������������������������������������������������������������������������������������������251 Generic Rigs������������������������������������������������������������������������������������������������������������������������������������������������������ 252 The Mecanim State Engine�������������������������������������������������������������������������������������������������������������������������������� 260 www.it-ebooks.info x Contents Humanoids��������������������������������������������������������������������������������������������������������������������������������������������������������� 264 BlendShapes������������������������������������������������������������������������������������������������������������������������������������������������������ 278 Native Animation�����������������������������������������������������������������������������������������������������������������������284 Summary�����������������������������������������������������������������������������������������������������������������������������������289 ■■Chapter 7: Populating the Game Environment���������������������������������������������������������������291 Design Strategies����������������������������������������������������������������������������������������������������������������������292 Creating the Environment ���������������������������������������������������������������������������������������������������������292 Utilizing the Prefabs������������������������������������������������������������������������������������������������������������������������������������������ 293 Revisiting the Gnomatic Garden Defender��������������������������������������������������������������������������������302 Occlusion Culling�����������������������������������������������������������������������������������������������������������������������307 Game Functionality��������������������������������������������������������������������������������������������������������������������315 Camera Refinements����������������������������������������������������������������������������������������������������������������������������������������� 315 Adding the Zombie Bunnies������������������������������������������������������������������������������������������������������������������������������� 320 Investigating Instantiation��������������������������������������������������������������������������������������������������������������������������������� 321 Spring Planting�������������������������������������������������������������������������������������������������������������������������������������������������� 330 Summary�����������������������������������������������������������������������������������������������������������������������������������337 ■■Chapter 8: Weaponry and Special Effects���������������������������������������������������������������������339 Weaponry����������������������������������������������������������������������������������������������������������������������������������339 Simple Projectiles���������������������������������������������������������������������������������������������������������������������������������������������� 339 Particle Systems�����������������������������������������������������������������������������������������������������������������������351 Legacy Particle System������������������������������������������������������������������������������������������������������������������������������������� 351 Dead Replacements������������������������������������������������������������������������������������������������������������������������������������������� 358 Shuriken Particle System���������������������������������������������������������������������������������������������������������������������������������� 360 Advanced Weaponry������������������������������������������������������������������������������������������������������������������382 Post-Processing Effects������������������������������������������������������������������������������������������������������������385 Summary�����������������������������������������������������������������������������������������������������������������������������������387 www.it-ebooks.info Contents xi ■■Chapter 9: Incorporating Unity 2D���������������������������������������������������������������������������������389 Finalizing the Game Play�����������������������������������������������������������������������������������������������������������389 Legacy GUI Text�������������������������������������������������������������������������������������������������������������������������������������������������� 389 Unity 2D�������������������������������������������������������������������������������������������������������������������������������������398 Basics���������������������������������������������������������������������������������������������������������������������������������������������������������������� 398 Summary�����������������������������������������������������������������������������������������������������������������������������������445 ■■Chapter 10: Menus and Levels��������������������������������������������������������������������������������������447 Ending the Game�����������������������������������������������������������������������������������������������������������������������447 Unity GUI ����������������������������������������������������������������������������������������������������������������������������������������������������������� 447 Starting the Game���������������������������������������������������������������������������������������������������������������������465 Start Screen������������������������������������������������������������������������������������������������������������������������������������������������������� 466 Adding the New Level to the Build�������������������������������������������������������������������������������������������������������������������� 479 Options and Player Settings������������������������������������������������������������������������������������������������������484 The Main Menu�������������������������������������������������������������������������������������������������������������������������������������������������� 484 The Settings Menu��������������������������������������������������������������������������������������������������������������������������������������������� 492 Credits��������������������������������������������������������������������������������������������������������������������������������������������������������������� 496 Retaining Data���������������������������������������������������������������������������������������������������������������������������499 DontDestroyOnLoad������������������������������������������������������������������������������������������������������������������������������������������� 499 Player Settings��������������������������������������������������������������������������������������������������������������������������511 Adjusting the Ambient Sound Volume���������������������������������������������������������������������������������������������������������������� 512 Adjusting Difficulty�������������������������������������������������������������������������������������������������������������������������������������������� 516 Final Build���������������������������������������������������������������������������������������������������������������������������������520 Summary�����������������������������������������������������������������������������������������������������������������������������������522 www.it-ebooks.info xii Contents ■■Chapter 11: Bonus Features������������������������������������������������������������������������������������������525 Creating a Zombie-Bunny Locator ��������������������������������������������������������������������������������������������525 Spy Map������������������������������������������������������������������������������������������������������������������������������������������������������������� 525 Adding a Power-Up��������������������������������������������������������������������������������������������������������������������533 Upgrading the Armaments��������������������������������������������������������������������������������������������������������538 Mecanim Masks and Layers������������������������������������������������������������������������������������������������������������������������������ 538 Creating a Laser Beam�������������������������������������������������������������������������������������������������������������������������������������� 548 Summary�����������������������������������������������������������������������������������������������������������������������������������563 ■■Appendix A: Rigging with Mixamo��������������������������������������������������������������������������������565 Before Starting Mixamo������������������������������������������������������������������������������������������������������������565 Rigging a Character with Mixamo���������������������������������������������������������������������������������������������566 Index���������������������������������������������������������������������������������������������������������������������������������575 www.it-ebooks.info About the Author Sue Blackman is a 3D artist and interactive applications author and instructor based in southern California She has taught 3ds Max and game classes for artists for well over ten years in top-rated community colleges and private schools, such as the Art Institute of California, and has been lead 3D artist on games for Activision through one of their subsidiaries She has worked in the industry for several years to help train Fortune 1000 companies, such as Boeing, Raytheon, and Northrop Grumman, to create serious games and training applications with game-based formats She has been involved with the commercial development of real-time 3D engines for well over ten years She is an avid tutorial writer and has created both tutorials, as a contributing author, and artwork for various 3ds Max books over the years, as well as training manuals for 3D authoring applications for serious games She has also written for ACM Siggraph on serious games, one of her favorite topics You can visit her web site at www.3dadventurous.com xiii www.it-ebooks.info About the Contributor Jenny Wang graduated with a BA in Math and minor in Computer Science from University of Southern California After working for many years in the corporate world, she became interested in video games She decided to combine her love of art with technology, which led to web development and 3D art creation with 3DS Max and Photoshop Learning and working with C# and the Unity game engine, she had a blast working on this book and working with Sue Blackman You can visit her web site at www.jennywangdesign.com xv www.it-ebooks.info About the Technical Reviewer Marc Schärer Schärer is an interactive media software engineer creating cutting-edge interactive media experiences for training, education, and entertainment with his company Gayasoft (http://www.gayasoft.net) located in Switzerland, using Unity since its early days in 2007 Marc Schärer has a strong background in the 3D graphics, network technology, software engineering and the interactive media fields After starting programming at the age of 11, he later studied Computer Science and Computational Science and Engineering at Swiss Federal Institute of Technology Zurich before working with various teams in North America, Oceania, and Japan to create compelling interactive experiences With the rise in popularity of serious games, interactive education, and immersive experiences, Gayasoft focuses on researching options and technologies for the next generation of interactive and immersive experiences We apply state-of-the-art AR and VR technologies (Vuforia, Metaio, Oculus Rift) and intuitive, innovative input technologies (Razer Hydra, STEM, Thalmic Myo, Leap Motion, Emotive Insight) xvii www.it-ebooks.info Acknowledgments Thanks go out to Jenny Wang for her invaluable help with the research, concept testing, and 2D art assets required for this book Thanks also to Barry Paul and John Irvin for introducing me to the fine art of potato-gun marksmanship (I still can’t believe they actually beaned a bunny with that overripe orange) and to Erik Toraasen, whose many ideas for garden-gnome gameplay threatened to push the book way over schedule From my 3ds Max class, I’d like to thank Brad Roach for “donating” the scarecrow used for some of the Mecanim experiments, and Jenny for taking the time to investigate Mixamo for character rigging (You can read her report in Appendix A.) The concept for the Gnomatic Garden Defender grew out of a frustration over keeping the destructive hoards of real bunnies out of my own garden and my fascination with the long-standing British love affair with garden gnomes Upon returning from the UK after spending two years pursuing an alternate education, I was introduced to the newly published book, Gnomes, with its fanciful illustrations of forest gnomes by Rein Poortvliet A #1 seller on the New York Times list, it became the de facto reference for the modern garden gnome Combining a common plaster garden gnome with a home-made potato gun seemed a perfect theme for the book’s project, so after creating a working prototype for the gnome, weapon, and game-play I headed out to the web to immerse myself deeper into the culture To my great delight, I discovered I wasn’t alone in my desire to arm the little folk Shawn Thorsson’s collection of “combat gnomes” so tickled my sense of the outrageous that I painted my own gnome’s potato gun to loosely resemble Shawn’s rocket launcher, paying homage to his marvelous creativity and craftsmanship Be sure to check out the “finest militarized lawn ornaments in the world” at http://thorssoli.etsy.com and his blog at http://protagonist4hire.blogspot.com/ xix www.it-ebooks.info ... thread on the Unity Teaching forum, http://forum .unity3 d.com/forums/23-Teaching, where both errata and version-change solutions will be posted and updated as necessary A search for the book’s... install Unity, if you don’t already have one, you will be required to create a Unity user account during the installation Your user account will provide access to the downloads, Unity Forum, Unity. .. Answers, and the Unity Asset Store The forum provides a place for discussion of all things Unity Answers is where you can go to get quick solutions to your queries, and the Unity Asset Store

Ngày đăng: 27/03/2019, 10:20

Xem thêm:

Mục lục

    Contents at a Glance

    About the Technical Reviewer

    Chapter 1: The Unity Editor

    Navigating the Scene View

    Understanding the Scene Gizmo

    Terrain Plants and Wind

    Chapter 3: Scene Navigation and Physics

    Virtual Keys: The InputManager

    The Character Controller Component

    The Character Motor Component

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN