
Unity 3D Game Development by Example Beginner's Guide A seat-of-your-pants manual for building fun, groovy little games quickly Ryan Henson Creighton BIRMINGHAM - MUMBAI Unity 3D Game Development by Example Beginner's Guide Copyright © 2010 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: September 2010 Production Reference: 1170910 Published by Packt Publishing Ltd. 32 Lincoln Road Olton Birmingham, B27 6PA, UK. ISBN 978-1-849690-54-6 www.packtpub.com Cover Image by Ed Maclean ([email protected]) Credits Author Editorial Team Leaders Ryan Henson Creighton Aditya Belpathak Reviewers Project Team Leader Aaron Cross Lata Basantani Clifford Peters Project Coordinator Chico Queiroz Srimoyee Ghoshal Acquisition Editor Proofreaders David Barnes Lynda Sliwoski Development Editor Chris Smith Dhiraj Chandiramani Jonathan Todd Technical Editor Production Coordinator Namita Sahni Arvindkumar Gupta Copy Editor Cover Work Lakshmi Menon Arvindkumar Gupta Indexer Monica Ajmera Mehta About the Author Ryan Henson Creighton is a veteran game developer, and the founder of Untold Entertainment Inc. (http://www.untoldentertainment.com/blog) where he creates games and applications for kids, teens, tweens, and preschoolers. Prior to founding Untold, Ryan worked as the Senior Game Developer at Canadian media conglomerate Corus Entertainment, creating advergames and original properties for YTV and Treehouse TV using Flash. Ryan is hard at work developing a suite of original products with Untold Entertainment. He maintains one of the most active and enjoyable blogs in the industry. When Ryan is not developing games, he's goofing off with his two little girls and his fun-loving wife in downtown Toronto. Big thanks to Cheryl, Cassandra, and Isabel for their love, their support, and their cinnamon rolls. Thanks to Jean-Guy Niquet for introducing me to Unity; to Jim "McMajorSupporter" McGinley for help with the book outline and ongoing mentorship; to the technical reviewers and Packt staff for letting me leave a few jokes in the book; and to David Barnes, for having such a great sense of humor in the first place. Special thanks to Michael Garforth and friends from the #Unity3D IRC channel on Freenode. I also want to thank Mom, God, and all the usual suspects. About the Reviewers Aaron Cross is a freelance video game developer based in Wellington, New Zealand. A successful musician and music producer, film-maker, and 3D artist, he switched his focus to game development in 2006. He has since produced four video game titles, and has provided art and programming solutions to Unity developers across the globe, from Canada and the U.K. to as far south as the Australian heritage sites on the continent of Antarctica. As well as commercial games, he has developed simulations for medical training, architectural visualization, science and research, conservation, and visual reconstructions for evidence used in court cases, using the Unity game engine. He can be contacted through his website: http://deepwater3d.com. Clifford Peters is an average Unity user who has enjoyed using Unity over the past few years. He plans to one day become a professional Unity user and to be able to use Unity in his career. To help realize this goal, Clifford is going to college to increase his knowledge in the fields of Math and Computer Science. Clifford has also helped to review the Unity book: Unity Game Development Essentials, Packt Publishing. Chico Queiroz is a multimedia designer living in Rio de Janeiro, Brazil. Having completed an MA degree in Digital Games Design from the University for the Creative Arts at Farnham, Chico has worked in areas such as webgames and advergames design and development. He has also published articles in academic game conferences and websites such as gameology.org, gamasutra.com, and gamecareerguide.com. Chico currently works as a Digital Designer at the Computer Graphics Technology Group (TeCGraf), a laboratory within the Pontifical Catholic University of Rio de Janeiro where he also works as a lecturer, teaching subjects such as 3D modeling and image editing to design students. Thank you Ana and Alice for all the love and support. Table of Contents Preface 1 Chapter 1: That's One Fancy Hammer! 7 Introducing Unity 3D 7 Unity takes over the world 8 Browser-based 3D? Welcome to the future 8 Time for action – install the Unity Web Player 8 Welcome to Unity 3D! 9 What can I build with Unity? 9 FusionFall 10 Completely hammered 10 Should we try to build FusionFall? 11 Another option 11 Off-Road Velociraptor Safari 12 Fewer features, more promise 13 Maybe we should build Off-Road Velociraptor Safari? 13 I bent my Wooglie 13 Big Fun Racing 14 Diceworks 14 Walk before you can run (or double jump) 15 There's no such thing as "finished" 16 Stop! Hammer time 16 Explore Demo island 17 The wonders of technology! 18 The Scene window 19 The Game window 20 The Hierarchy 20 The Project panel 21 The Inspector 22 Invade Island Demo as a paratrooper 24 Table of Contents Layers and layout dropdowns 26 Playback controls 26 Scene controls 26 Don't stop there—live a little! 27 Summary 28 Big ambition, tinyames g 28 Chapter 2: Let's Start with the Sky 29 That little lightbulb 30 The siren song of 3D 30 Features versus content 31 A game with no features 32 Mechanic versus skin 32 Trapped in your own skin 33 That singular piece of joy 34 One percent inspiration 34 Motherload 34 Heads up! 36 Artillery Live! 37 Pong 41 The mechanic that launched a thousand games 43 Toy or story 45 Redefining the sky 46 Summary 47 Let's begin 47 Chapter 3: Game #1: Ticker Taker 49 Kick up a new Unity project 49 Where did everything go? 51 'Tis volley 51 Keep the dream alive 52 Slash and burn! 52 The many faces of keep-up 53 Creating the ball and the hitter 53 Time for action – create the ball 53 A ball by any other name 54 Time for action – enamer the ball 55 Origin story 55 XYZ/RGB 56 Time for action – move the ball into the "sky" 57 Time for action – shrink the ball 58 Time for action – save your Scene 59 [ ii ] Table of Contents Time for action – add the Paddle 60 What's a Mesh? 62 Poly wanna crack your game performance? 64 Keeping yourself in the dark 65 Time for action – add a light 65 Time for action – move and rotate the light 66 Extra credit 69 Are you a luminary? 69 Who turned out the lights? 69 Darkness reigns 69 Time for action – estt your game 70 Let's get physical 70 Time for action – add physics to your game 70 Understanding the gravity of the situation 71 More bounce to the ounce 72 Time for action – make the ball bouncy 72 Summary 74 Following the script 75 Chapter 4: Code Comfort 77 What is code? 77 Time for action – write your first Unity Script 77 A leap of faith 79 Lick it and stick it 80 Disappear Me! 80 It's all Greek to me 80 You'll never go hungry again 81 With great sandwich comes great responsibility 82 Examining the code 82 Time for action – find the Meshenderer R component 83 Time for action – make the ball reappear 84 Ding! 84 Time for action – journey to the Unity Script Reference 85 The Renderer class 86 What's another word for "huh"? 89 It's been fun 90 Time for action – unstick the Script 90 Gone, but not forgotten 91 Why code? 91 Equip your baby bird 92 Time for action – create a new MouseFollow Script 92 [ iii ] Table of Contents A capital idea 94 Animating with odec 95 Time for action – animate the Paddle 95 Pick a word—(almost) any word 97 Screen Coordinates versus World Coordinates 98 Move the Paddle 98 Worst. Game. Ever. 99 See the matrix 99 Time for action – animate the Paddle 99 A tiny bit o' math 100 Tracking the numbers 100 Futzing with the numbers 101 Time for action – log the new number 101 She's A-Work! 102 Somebody get me a bucket 102 Time for action – declare a variable to store the screen midpoint 103 Using all three dees 105 Time for action – ollowf the Y position of the mouse 106 A keep-up game for robots 106 Once more into the breach 107 Time for action – evisitr the Unity Language Reference 107 Our work here is done 108 Time for action – add the sample odec to your Script 108 One final tweak 110 What's a quaternion? 110 Wait, what's a quaternion? 110 WHAT THE HECK IS A QUATERNION?? 110 Educated guesses 111 More on Slerp 112 Right on target 112 Keep it up 114 Beyond the game mechanic 115 Chapter 5: Game #2: Robot Repair 117 You'll totally flip 118 A blank slate 119 You're making a scene 120 Time for action – set up two Scenes 120 No right answer 121 Time for action – prepare the GUI 121 The beat of your own drum 123 [ iv ] Table of Contents Time for action – create and link a custom GUI skin 123 Time for action – create a button UI control 124 Want font? 128 Cover your
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages384 Page
-
File Size-