Unity 3D Game Development by Example Beginner's Guide
2.5/5
()
About this ebook
Beginner game developers are wonderfully optimistic, passionate, and ambitious. But that ambition is often dangerous! Too often, budding indie developers and hobbyists bite off more than they can chew. Some of the most popular games in recent memory - Doodle Jump, Paper Toss, and Canabalt, to name a few - have been fun, simple games that have delighted players and delivered big profits to their creators. This is the perfect climate for new game developers to succeed by creating simple games with Unity 3D, starting today.
This book starts you off on the right foot, emphasizing small, simple game ideas and playable projects that you can actually finish. The complexity of the games increases gradually as we progress through the chapters. The chosen examples help you learn a wide variety of game development techniques. With this understanding of Unity 3D and bite-sized bits of programming, you can make your own mark on the game industry by finishing fun, simple games.
This book shows you how to build crucial game elements that you can reuse and re-skin in many different games, using the phenomenal (and free!) Unity 3D game engine. It initiates you into indie game culture by teaching you how to make your own small, simple games using Unity3D and some gentle, easy-to-understand code. It will help you turn a rudimentary keep-up game into a madcap race through hospital hallways to rush a still-beating heart to the transplant ward, program a complete 2D game using Unity's User Interface controls, put a dramatic love story spin on a simple catch game, and turn that around into a classic space shooter with spectacular explosions and "pew" sounds! By the time you're finished, you'll have learned to develop a number of important pieces to create your own games that focus in on that small, singular piece of joy that makes games fun.
This book shoots straight for the heart of fun, simple game design and keeps shooting until you have all the pieces you need to assemble your own great games.
ApproachThe book takes a clear, step-by-step approach to building small, simple game projects. It focuses on short, attainable goals so that the reader can finish something, instead of trying to create a complex RPG or open-world game that never sees the light of day. This book encourages readers hungry for knowledge. It does not go into gory detail about how every little knob and dial functions - that's what the software manual is for! Rather, this book is the fastest path from zero to finished game using the Unity 3D engine.
Who this book is forIf you've ever wanted to develop games, but have never felt "smart" enough to deal with complex programming, this book is for you. It's also a great kick-start for developers coming from other tools like Flash, Unreal Engine, and Game Maker Pro.
Ryan Henson Creighton
Ryan Henson Creighton is a veteran game developer, and the founder of Untold Entertainment Inc. (http://www.untoldentertainment.com) where he creatively consults on games and applications. Untold Entertainment creates fantastically fun interactive experiences for players of all ages. Prior to founding Untold, Ryan worked as the Senior Game Developer at Canadian media conglomerate Corus Entertainment, where he created over fifty advergames and original properties for the YTV, Treehouse TV, and W networks. Ryan is the co-creator of Sissy's Magical Ponycorn Adventure, the game he authored with his then five-year-old daughter Cassandra. Ryan is the Vice President of the IGDA Toronto Chapter. He is also the author of the book that you are currently reading. When Ryan is not developing games, he's goofing off with his two little girls and his funloving wife in downtown Toronto.
Read more from Ryan Henson Creighton
Unity 3.x Game Development by Example Beginner's Guide Rating: 3 out of 5 stars3/5Unity 4.x Game Development by Example Beginner's Guide Rating: 3 out of 5 stars3/5
Related to Unity 3D Game Development by Example Beginner's Guide
Related ebooks
Unity Game Development Essentials Rating: 5 out of 5 stars5/5Mastering Unity 2D Game Development - Second Edition Rating: 0 out of 5 stars0 ratingsUnity Game Development Scripting Rating: 0 out of 5 stars0 ratingsMastering Unity 2D Game Development Rating: 5 out of 5 stars5/5Unreal Development Kit Game Design Cookbook Rating: 0 out of 5 stars0 ratingsUnreal Engine Game Development Cookbook Rating: 0 out of 5 stars0 ratingsUnreal Engine 4.X By Example Rating: 0 out of 5 stars0 ratingsLearning C# by Developing Games with Unity 5.x - Second Edition Rating: 5 out of 5 stars5/5Getting Started with Unity 5.x 2D Game Development Rating: 0 out of 5 stars0 ratingsLearning C++ by Creating Games with UE4 Rating: 3 out of 5 stars3/5Unity in Action, Third Edition: Multiplatform game development in C# Rating: 0 out of 5 stars0 ratingsUnreal Development Kit Game Programming with UnrealScript Beginner's Guide Rating: 3 out of 5 stars3/5Learning Unreal Engine Game Development Rating: 5 out of 5 stars5/5Learning C# by Developing Games with Unity 3D Beginner's Guide Rating: 5 out of 5 stars5/5SFML Game Development Rating: 0 out of 5 stars0 ratingsUnity 5.x Cookbook Rating: 0 out of 5 stars0 ratingsUnity Android Game Development by Example Beginner's Guide Rating: 4 out of 5 stars4/5Phaser III Game Prototyping Rating: 0 out of 5 stars0 ratingsUnity from Zero to Proficiency (Proficient): Unity from Zero to Proficiency, #5 Rating: 5 out of 5 stars5/5OpenGL Game Development By Example Rating: 0 out of 5 stars0 ratingsLearning LibGDX Game Development - Second Edition Rating: 0 out of 5 stars0 ratingsHTML5 Game Development HOTSHOT Rating: 0 out of 5 stars0 ratingsGoogle SketchUp for Game Design: Beginner's Guide Rating: 5 out of 5 stars5/5GameMaker Cookbook Rating: 0 out of 5 stars0 ratingsMastering LibGDX Game Development Rating: 0 out of 5 stars0 ratingsSwipe This!: The Guide to Great Touchscreen Game Design Rating: 4 out of 5 stars4/5HTML5 Game Development with GameMaker Rating: 0 out of 5 stars0 ratingsProcedural Content Generation for C++ Game Development Rating: 3 out of 5 stars3/5SFML Game Development By Example Rating: 0 out of 5 stars0 ratingsDirect3D Rendering Cookbook Rating: 0 out of 5 stars0 ratings
Computers For You
How to Create Cpn Numbers the Right way: A Step by Step Guide to Creating cpn Numbers Legally Rating: 4 out of 5 stars4/5Procreate for Beginners: Introduction to Procreate for Drawing and Illustrating on the iPad Rating: 0 out of 5 stars0 ratingsSQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5Mastering ChatGPT: 21 Prompts Templates for Effortless Writing Rating: 5 out of 5 stars5/5Learning the Chess Openings Rating: 5 out of 5 stars5/5CompTIA Security+ Get Certified Get Ahead: SY0-701 Study Guide Rating: 5 out of 5 stars5/5The ChatGPT Millionaire Handbook: Make Money Online With the Power of AI Technology Rating: 0 out of 5 stars0 ratingsThe Designer's Web Handbook: What You Need to Know to Create for the Web Rating: 0 out of 5 stars0 ratingsPractical Lock Picking: A Physical Penetration Tester's Training Guide Rating: 5 out of 5 stars5/5Creating Online Courses with ChatGPT | A Step-by-Step Guide with Prompt Templates Rating: 4 out of 5 stars4/5CompTIA IT Fundamentals (ITF+) Study Guide: Exam FC0-U61 Rating: 0 out of 5 stars0 ratingsChatGPT Ultimate User Guide - How to Make Money Online Faster and More Precise Using AI Technology Rating: 0 out of 5 stars0 ratingsDeep Search: How to Explore the Internet More Effectively Rating: 5 out of 5 stars5/5Remote/WebCam Notarization : Basic Understanding Rating: 3 out of 5 stars3/5People Skills for Analytical Thinkers Rating: 5 out of 5 stars5/5Slenderman: Online Obsession, Mental Illness, and the Violent Crime of Two Midwestern Girls Rating: 4 out of 5 stars4/5Elon Musk Rating: 4 out of 5 stars4/5The Ridiculously Simple Guide to Google Docs: A Practical Guide to Cloud-Based Word Processing Rating: 0 out of 5 stars0 ratingsUltimate Guide to Mastering Command Blocks!: Minecraft Keys to Unlocking Secret Commands Rating: 5 out of 5 stars5/5Master Builder Roblox: The Essential Guide Rating: 4 out of 5 stars4/5Web Designer's Idea Book, Volume 4: Inspiration from the Best Web Design Trends, Themes and Styles Rating: 4 out of 5 stars4/5CompTIA Security+ Practice Questions Rating: 2 out of 5 stars2/5
Reviews for Unity 3D Game Development by Example Beginner's Guide
2 ratings1 review
- Rating: 2 out of 5 stars2/5for older versions of unity.
uses depreciated code.
if you download an older version this would be ok.
Book preview
Unity 3D Game Development by Example Beginner's Guide - Ryan Henson Creighton
Table of Contents
Unity 3D Game Development by Example
Credits
About the Author
About the Reviewers
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Time for action - heading
What just happened?
Have a go hero - heading
Reader feedback
Customer support
Errata
Piracy
Questions
1. That's One Fancy Hammer!
Introducing Unity 3D
Unity takes over the world
Browser-based 3D? Welcome to the future
Time for action - install the Unity Web Player
Welcome to Unity 3D!
What can I build with Unity?
FusionFall
Completely hammered
Should we try to build FusionFall?
Another option
Off-Road Velociraptor Safari
Fewer features, more promise
Maybe we should build Off-Road Velociraptor Safari?
I bent my Wooglie
Big Fun Racing
Diceworks
Walk before you can run (or double jump)
There's no such thing as finished
Stop! Hammer time
Explore Demo island
The wonders of technology!
The Scene window
The Game window
The Hierarchy
The Project panel
The Inspector
Invade Island Demo as a paratrooper
Layers and layout dropdowns
Playback controls
Scene controls
Don't stop there live a little!
Summary
Big ambition, tiny games
2. Let's Start with the Sky
That little lightbulb
The siren song of 3D
Features versus content
A game with no features
Mechanic versus skin
Trapped in your own skin
That singular piece of joy
One percent inspiration
Motherload
Heads up!
Artillery Live!
Pong
The mechanic that launched a thousand games
Have a go hero - redesign your favorite games
Toy or story
Pop quiz finding that singular piece of joy
Redefining the sky
Summary
Let's begin
3. Game #1: Ticker Taker
Kick up a new Unity project
Where did everything go?
'Tis volley
Keep the dream alive
Slash and burn!
The many faces of keep-up
Creating the ball and the hitter
Time for action - create the ball
What just happened that's all there is to it?
A ball by any other name
Time for action - rename the ball
Origin story
XYZ/RGB
Time for action - move the ball into the sky
Time for action - shrink the ball
Time for action - save your Scene
Time for action - add the Paddle
What's a Mesh?
Poly wanna crack your game performance?
Keeping yourself in the dark
Time for action - add a light
Time for action - move and rotate the light
Have a go hero - let there be (additional) light
Extra credit
Are you a luminary?
Who turned out the lights?
Darkness reigns
Time for action - test your game
Let's get physical
Time for action - add physics to your game
Understanding the gravity of the situation
More bounce to the ounce
Time for action - make the ball bouncy
Have a go hero - DIY physic materials
Summary
Following the script
4. Code Comfort
What is code?
Time for action - write your first Unity Script
A leap of faith
Lick it and stick it
Disappear Me!
What just happened?
It's all Greek to me
You'll never go hungry again
With great sandwich comes great responsibility
Examining the code
Time for action - find the Mesh Renderer component
Time for action - make the ball reappear
Ding!
Time for action - journey to the Unity Script Reference
The Renderer class
Have a go hero - pulling the wings off flies
What's another word for huh
?
It's been fun
Time for action - unstick the Script
Gone, but not forgotten
Why code?
Equip your baby bird
Time for action - create a new MouseFollow Script
What just happened?
A capital idea
Animating with code
Time for action - animate the Paddle
What just happened - what witchcraft is this?
Why didn't the paddle animate before?
Pick a word (almost) any word
Screen Coordinates versus World Coordinates
Move the Paddle
Worst. Game. Ever.
See the matrix
Time for action - animate the Paddle
A tiny bit o' math
Tracking the numbers
Futzing with the numbers
Time for action - log the new number
She's A-Work!
Somebody get me a bucket
Time for action - declare a variable to store the screen midpoint
What just happened we've Gone too Var
Using all three dees
Time for action - follow the Y position of the mouse
A keep-up game for robots
Once more into the breach
Time for action - revisit the Unity Language Reference
Our work here is done
Time for action - add the sample code to your Script
One final tweak
What's a quaternion?
Wait, what's a quaternion?
WHAT THE HECK IS A QUATERNION??
Educated guesses
More on Slerp
Right on target
Have a go hero - time to break stuff
Keep it up
Beyond the game mechanic
5. Game #2: Robot Repair
You'll totally flip
A blank slate
You're making a scene
Time for action - set up two Scenes
No right answer
Time for action - prepare the GUI
The beat of your own drum
Time for action - create and link a custom GUI skin
What just happened?
Time for action - create a button UI control
What just happened?
Have a go hero - no sense sitting around on your button
Want font?
Cover your assets
Time for action - nix the mipmapping
Front and center
Time for action - center the button
What just happened investigating the code
To the game!
Time for action - add both scenes to the build list
Set the stage for robots
Time for action - prepare the game Scene
The game plan
Have some class!
Time for action - store the essentials
Start me up
Going loopy
The anatomy of a loop
To nest is best
Seeing is believing
Time for action - create an area to store the grid
Have a go hero - don't take my word for it!
Build that grid
What just happened grokking the code
Now you're playing with power!
6. Game #2: Robot Repair Part 2
From zero to game in one chapter
Finding your center
Time for action - center the game grid vertically
What just happened?
Time for action - center the game grid horizontally
What just happened coding like a ninja
Down to the nitty griddy
Do the random card shuffle
Time for action - prepare to build the deck
Let's break some robots
Time for action - build the deck
What just happened dissecting the bits
Time for action - modify the img argument
What just happened?
What exactly is this
?
Have a go hero - grokketh-thou Random.Range()?
Random reigns supreme
Second dragon down
Time to totally flip
Time for action - make the cards two-sided
Time for action - build the card-flipping function
Time for action - build the card-flipping function
What just happened dissecting the flip
Pumpkin eater
What just happened?
Stabby McDragonpoker rides again
Game and match
Time for action - ID the cards
What just happened?
Time for action - compare the IDs
What just happened?
On to the final boss
Endgame
Time for action - check for victory
What just happened?
Have a go hero - extra credit
Endgame
Bring. It. On.
7. Don't Be a Clock Blocker
Apply pressure
Time for action - prepare the clock script
Time for more action prepare the clock text
Still time for action change the clock text color
Time for action - rides again create a font texture and material
Time for action - what's with the tiny font?
What just happened - was that seriously magic?
Time for action - prepare the clock code
What just happened that's a whole lotta nothing
Time for action - create the countdown logic
Time for action - display the time on-screen
What just happened what about that terrifying code?
Picture it
Time for action - grab the picture clock graphics
What just happened you can do that?
Time for action - flex those GUI muscles
What just happened how does it work?
The incredible shrinking clock
Keep your fork there's pie!
Pop quiz how do we build it?
How they did it
Time for action - rig up the textures
Time for action - write the pie chart Script
What just happened?
Time for action - commence operation pie clock
What just happened explaining away the loose ends
Time for action - positioning and scaling the clock
Have a go hero - rock out with your clock out
Unfinished business
8. Ticker Taker
Welcome to Snoozeville
Model behavior
Time for action - explore the models
Time for action - hands up!
What just happened size matters
Time for action - change the FBX import scale settings
Time for action - make the Mesh Colliders convex
Time for action - make the Hands and Tray follow the Mouse
What just happened monkey see, monkey do
Time for action - get your heart on
Time for action - ditch the Ball and Paddle
What just happened bypass the aorta
Time for action - material witness
What just happened understanding Materials
Have a go hero - add Materials to the other models
This Just In: This Game Blows
Time for action - multiple erections
Time for action - create a font texture
Time for action - create the HeartBounce Script
What just happened charting a collision course
Time for action - tag the tray
Time for action - tweak the bounce
What just happened storing velocity
Time for action - keeping track of the bounces
Time for action - add the lose condition
What just happened understanding the code
Time for action - add the Play Again button
What just happened?
Ticker Taken
9. Game #3: The Break-Up
Time for action - bombs away!
Time for action - poke those particles
Time for action - create a Spark Material
Have a go hero - time to ignite your creative Spark
Time for action - prefabulous
What just happened what's a Prefab?
Time for action - lights, camera, apartment
Time for action - add the character
Time for action - register the animations
Time for action - script the character
What just happened stepping through the step
code
Time for action - open the Pod Bay Door, Hal
Time for action - collision-enable the Character
Time for action - re-Prefab the Prefab
Time for action - apocalypse now?
Time for action - go boom
Time for action - the point of impact
Time for action - hook up the explosion
Summary
10. Game #3: The Break-Up Part 2
Time for action - amass some glass
Time for action - create a Particle System
What just happened getting smashed
Time for action - make it edgier!
What just happened I fall to pieces
Time for action - contain the explosion
What just happened duped?
Time for action - let's get lazy
What just happened FallingObject: The PuppetMaster
Very variable?
Terminal velocity is a myth bombs fall faster
What just happened when Game Objects collide?
Time for action - tag the objects
Time for action - write the collision detection code
Time for action - animation interrupts
What just happened the impenetrable stare
Time for action - add facial explosions
What just happened raindrops keep 'sploding on my head
Time for action - make some noise
Time for action - add sounds to the FallingObjectScript
What's the catch?
Have a go hero - sound off
Time for action - mix it up a bit
Have a go hero - filling in the gaps
Summary
11. Game #4: Shoot the Moon
Time for action - duplicate your game project
Time for action - space this sucker up a bit
Time for action - enter the hero
Time for action - it's a hit!
Time for action - bring on the bad guys
Time for action - do some housekeeping
Time for action - fixing the fall
Time for action - tweak the hero
What just happened hooray for lazy!
Time for action - give up the func
Time for action - itchy trigger finger
Time for action - futurize the bullet
Time for action - building Halo
Time for action - fire!
Time for action - Code Do-Si-Do
What just happened eat lead
Time for action - the maaagic of aaaarguments
Time for action - add the most important part of any spaceshooter
Last year's model
Have a go hero - filling in the empty space
Summary
More hospitality
12. Action!
Open heart surgery
Time for action - haul in the hallway
Time for action - meet me at camera two
Time for action - adjust the Main Camera
Time for action - deck the halls
Time for action - turn on the lights
Time for action - set up the camera rig
Time for action - animate the bouncer
What just happened red and raging
Time for action - I like to move it move it
Have a go hero - bounce your brains out
Time for action - animate the runner
What just happened holy hospital rampage, Batman!
Time for action - how to handle
Nurse Slipperfoot
Time for action - you spin me right round
Have a go hero - give Robo-Nurse a soul
Have a go hero - use your new-found powers for good
Time for action - deploy your game
Time to grow
Beyond the book
A. References
Online resources
Offline resources
Free development tools
Graphics
Sound
Content sites
Game Portals
Index
Unity 3D Game Development by Example
Unity 3D Game Development by Example
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 (<edmaclean@gmail.com> )
Credits
Author
Ryan Henson Creighton
Reviewers
Aaron Cross
Clifford Peters
Chico Queiroz
Acquisition Editor
David Barnes
Development Editor
Dhiraj Chandiramani
Technical Editor
Namita Sahni
Copy Editor
Lakshmi Menon
Indexer
Monica Ajmera Mehta
Editorial Team Leaders
Aditya Belpathak
Project Team Leader
Lata Basantani
Project Coordinator
Srimoyee Ghoshal
Proofreaders
Lynda Sliwoski
Chris Smith
Jonathan Todd
Production Coordinator
Arvindkumar Gupta
Cover Work
Arvindkumar Gupta
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.
Preface
Game Developer
has rapidly replaced firetruck
as the number one thing that kids want to be when they grow up. Gone are the days when aspiring developers needed a university education, a stack of punch cards, and a room-sized computer to program a simple game. With digital distribution and the availability of inexpensive (or free) games development tools like Unity 3D, the democratization of game development is well underway.
But just as becoming a firetruck is fraught with perils, so too is game development. Too often, aspiring developers underestimate the sheer enormity of the multidisciplinary task ahead of them. They bite off far more than they can chew, and eventually drift away from their game development dreams to become lawyers or dental hygienists. It's tragic. This book bridges the gap between I wanna make games!
and I just made a bunch of games!
by focusing on small, simple projects that you can complete before you reach the bottom of a bag of corn chips.
What this book covers
Chapter 1, That's One Fancy Hammer!, introduces you to Unity 3D an amazing game engine that enables you to create games and deploy them to a number of different devices, including (at the time of writing) the Web, PCs, iOS platforms, and WiiWare, with modules for Android and Xbox Live Arcade deployment in the works. You'll play a number of browser-based Unity 3D games to get a sense of what the engine can handle, from a massively-multiplayer online game all the way down to a simple kart racer. You'll download and install your own copy of Unity 3D, and mess around with the beautiful Island Demo that ships with the product.
Chapter 2, Let's Start with the Sky, explores the difference between a game's skin and its mechanic. Using examples from video game history, including Worms, Mario Tennis, and Scorched Earth, we'll uncover the small, singular piece of joy upon which more complicated and impressive games are based. By concentrating on the building blocks of video games, we'll learn how to distil an unwieldy behemoth of a game concept down to a manageable starter project.
Chapter 3, Game #1: Ticker Taker, puts you in the pilot seat of your first Unity 3D game project. We'll explore the Unity environment and learn how to create and place primitives, add Components like physic materials and rigidbodies, and make a ball bounce on a paddle using Unity's built-in physics engine without ever breaking a sweat.
Chapter 4, Code Comfort, continues the keep-up game project by gently introducing scripting. Just by writing a few simple, thoroughly-explained lines of code, you can make the paddle follow the mouse around the screen to add some interactivity to the game. This chapter includes a crash course in game scripting that will renew your excitement for programming where high school computer classes may have failed you.
Chapter 5, Game#2: Robot Repair, introduces an often-overlooked aspect of game development: front-of-house
User Interface design the buttons, logos, screens, dials, bars, and sliders that sit in front of your game is a complete discipline unto itself. Unity 3D includes a very meaty Graphical User Interface system that allows you to create controls and fiddly bits to usher your players through your game. We'll explore this system, and start building a complete two-dimensional game with it! By the end of this chapter, you'll be halfway to completing Robot Repair, a colorful matching game with a twist.
Chapter 6, Game#2: Robot Repair Part 2, picks up where the last chapter left off. We'll add interactivity to our GUI-based game, and add important tools to our game development tool belt, including drawing random numbers and limiting player control. When you're finished with this chapter, you'll have a completely playable game using only the Unity GUI system, and you'll have enough initial knowledge to explore the system yourself to create new control schemes for your games.
Chapter 7, Don't be a Clock Blocker, is a standalone chapter that shows you how to build three different game clocks: a number-based clock, a depleting bar clock, and a cool pie wedge clock, all of which use the same underlying code. You can then add one of these clocks to any of the game projects in this book, or reuse the code in a game of your own.
Chapter 8, Ticker Taker, revisits the keep-up game from earlier chapters and replaces the simple primitives with 3D models. You'll learn how to create materials and apply them to models that you import from external art packages. You'll also learn how to detect collisions between Game Objects, and how to print score results to the screen. By the end of this chapter, you'll be well on your way to building Ticker Taker a game where you bounce a still-beating human heart on a hospital dinner tray in a mad dash for the transplant ward!
Chapter 9, Game#3: The Break-Up is a wild ride through Unity's built-in particle system that enables you to create effects like smoke, fire, water, explosions, and magic. We'll learn how to add sparks and explosions to a 3D bomb model, and how to use scripting to play and stop animations on a 3D character. You'll need to know this stuff to complete The Break-Up a catch game that has you grabbing falling beer steins and dodging explosives tossed out the window by your jilted girlfriend.
Chapter 10, Game#3: The Break-Up Part 2, completes The Break-Up game from the previous chapter. You'll learn how to reuse scripts on multiple different Game Objects, and how to build Prefabs, which enable you to modify a whole army of objects with a single click. You'll also learn to add sound effects to your games for a much more engaging experience.
Chapter 11, Game #4: Shoot the Moon, fulfills the promise of Chapter 2 by taking you through a re-skin exercise on The Break-Up. By swapping out a few models, changing the background, and adding a shooting mechanic, you'll turn a game about catching beer steins on terra firma into an action-packed space shooter! In this chapter, you'll learn how to set up a two-camera composite shot, how to use code to animate Game Objects, and how to re-jig your code to save time and effort.
Chapter 12, Action!, takes you triumphantly back to Ticker Taker for the coup de grace: a bouncing camera rig built with Unity's built-in animation system that flies through a model of a hospital interior. By using the two-camera composite from The Break-Up, you'll create the illusion that the player is actually running through the hospital bouncing a heart on a tin tray. The chapter ends with a refresher on bundling your project and deploying it to the Web so that your millions of adoring fans can finally experience your masterpiece.
What you need for this book
You'll need to be in possession of a sturdy hat, a desk chair equipped with a seatbelt, and an array of delicious snack foods that won't get these pages all cheesy (if you're reading the e-book version, you're all set). Early chapters walk you through downloading and installing Unity 3D (http://unity3d.com/unity/download/). A list of resources and links to additional software can be found in the appendix.
Who this book is for
If you've ever wanted to develop games, but have never felt smart
enough to deal with complex programming, this book is for you. It's also a great kickstart for developers coming from other tools like Flash, Unreal Engine, and Game Maker Pro.
Conventions
In this book, you will find several headings appearing frequently.
To give clear instructions of how to complete a procedure or task, we use:
Time for action - heading
Action 1
Action 2
Action 3
Instructions often need some extra explanation so that they make sense, so they are followed with:
What just happened?
This heading explains the working of tasks or instructions that you have just completed.
You will also find some other learning aids in the book, including:
Have a go hero - heading
These set practical challenges and give you ideas for experimenting with what you have learned.
You will also find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and explanations of their meanings.
Code words in text are shown as follows: Find the BuildGrid() function.
A block of code is set as follows:
function Update () {
renderer.enabled = false;
}
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
var smooth