Unity 3D Game Development by Example

Book description

A seat-of-your-pants manual for building fun, groovy little games quickly

  • Build fun games using the free Unity 3D game engine even if you've never coded before
  • Learn how to "skin" projects to make totally different games from the same file – more games, less effort!
  • Deploy your games to the Internet so that your friends and family can play them
  • Packed with ideas, inspiration, and advice for your own game design and development
  • Stay engaged with fresh, fun writing that keeps you awake as you learn

In Detail

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.

Table of contents

  1. Unity 3D Game Development by Example
    1. Table of Contents
    2. Unity 3D Game Development by Example
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Time for action - heading
        1. What just happened?
        2. Have a go hero - heading
      6. Reader feedback
      7. Customer support
        1. Errata
        2. Piracy
        3. Questions
    7. 1. That's One Fancy Hammer!
      1. Introducing Unity 3D
      2. Unity takes over the world
      3. Browser-based 3D? Welcome to the future
      4. Time for action - install the Unity Web Player
      5. Welcome to Unity 3D!
      6. What can I build with Unity?
        1. FusionFall
      7. Completely hammered
      8. Should we try to build FusionFall?
      9. Another option
        1. Off-Road Velociraptor Safari
          1. Fewer features, more promise
          2. Maybe we should build Off-Road Velociraptor Safari?
      10. I bent my Wooglie
        1. Big Fun Racing
        2. Diceworks
      11. Walk before you can run (or double jump)
      12. There's no such thing as "finished"
      13. Stop! Hammer time
        1. Explore Demo island
      14. The wonders of technology!
      15. The Scene window
        1. The Game window
        2. The Hierarchy
        3. The Project panel
        4. The Inspector
        5. Invade Island Demo as a paratrooper
        6. Layers and layout dropdowns
        7. Playback controls
        8. Scene controls
      16. Don't stop there live a little!
      17. Summary
        1. Big ambition, tiny games
    8. 2. Let's Start with the Sky
      1. That little lightbulb
      2. The siren song of 3D
      3. Features versus content
      4. A game with no features
      5. Mechanic versus skin
      6. Trapped in your own skin
      7. That singular piece of joy
      8. One percent inspiration
      9. Motherload
      10. Heads up!
      11. Artillery Live!
      12. Pong
      13. The mechanic that launched a thousand games
        1. Have a go hero - redesign your favorite games
      14. Toy or story
        1. Pop quiz finding that singular piece of joy
      15. Redefining the sky
      16. Summary
        1. Let's begin
    9. 3. Game #1: Ticker Taker
      1. Kick up a new Unity project
        1. Where did everything go?
      2. 'Tis volley
      3. Keep the dream alive
      4. Slash and burn!
      5. The many faces of keep-up
      6. Creating the ball and the hitter
      7. Time for action - create the ball
        1. What just happened that's all there is to it?
      8. A ball by any other name
      9. Time for action - rename the ball
      10. Origin story
        1. XYZ/RGB
      11. Time for action - move the ball into the "sky"
      12. Time for action - shrink the ball
      13. Time for action - save your Scene
      14. Time for action - add the Paddle
        1. What's a Mesh?
        2. Poly wanna crack your game performance?
      15. Keeping yourself in the dark
      16. Time for action - add a light
      17. Time for action - move and rotate the light
        1. Have a go hero - let there be (additional) light
        2. Extra credit
      18. Are you a luminary?
        1. Who turned out the lights?
        2. Darkness reigns
      19. Time for action - test your game
      20. Let's get physical
      21. Time for action - add physics to your game
      22. Understanding the gravity of the situation
      23. More bounce to the ounce
      24. Time for action - make the ball bouncy
        1. Have a go hero - DIY physic materials
      25. Summary
        1. Following the script
    10. 4. Code Comfort
      1. What is code?
      2. Time for action - write your first Unity Script
      3. A leap of faith
      4. Lick it and stick it
        1. Disappear Me!
        2. What just happened?
      5. It's all Greek to me
      6. You'll never go hungry again
      7. With great sandwich comes great responsibility
      8. Examining the code
      9. Time for action - find the Mesh Renderer component
      10. Time for action - make the ball reappear
      11. Ding!
      12. Time for action - journey to the Unity Script Reference
      13. The Renderer class
        1. Have a go hero - pulling the wings off flies
      14. What's another word for "huh"?
      15. It's been fun
      16. Time for action - unstick the Script
      17. Gone, but not forgotten
      18. Why code?
      19. Equip your baby bird
      20. Time for action - create a new MouseFollow Script
        1. What just happened?
      21. A capital idea
      22. Animating with code
      23. Time for action - animate the Paddle
        1. What just happened - what witchcraft is this?
        2. Why didn't the paddle animate before?
      24. Pick a word (almost) any word
      25. Screen Coordinates versus World Coordinates
      26. Move the Paddle
      27. Worst. Game. Ever.
      28. See the matrix
      29. Time for action - animate the Paddle
      30. A tiny bit o' math
      31. Tracking the numbers
      32. Futzing with the numbers
      33. Time for action - log the new number
      34. She's A-Work!
      35. Somebody get me a bucket
      36. Time for action - declare a variable to store the screen midpoint
        1. What just happened we've Gone too Var
      37. Using all three dees
      38. Time for action - follow the Y position of the mouse
      39. A keep-up game for robots
      40. Once more into the breach
      41. Time for action - revisit the Unity Language Reference
      42. Our work here is done
      43. Time for action - add the sample code to your Script
      44. One final tweak
        1. What's a quaternion?
        2. Wait, what's a quaternion?
        3. WHAT THE HECK IS A QUATERNION??
      45. Educated guesses
        1. More on Slerp
      46. Right on target
        1. Have a go hero - time to break stuff
      47. Keep it up
        1. Beyond the game mechanic
    11. 5. Game #2: Robot Repair
      1. You'll totally flip
        1. A blank slate
        2. You're making a scene
      2. Time for action - set up two Scenes
        1. No right answer
      3. Time for action - prepare the GUI
        1. The beat of your own drum
      4. Time for action - create and link a custom GUI skin
        1. What just happened?
      5. Time for action - create a button UI control
        1. What just happened?
        2. Have a go hero - no sense sitting around on your button
        3. Want font?
        4. Cover your assets
      6. Time for action - nix the mipmapping
        1. Front and center
      7. Time for action - center the button
        1. What just happened investigating the code
        2. To the game!
      8. Time for action - add both scenes to the build list
        1. Set the stage for robots
      9. Time for action - prepare the game Scene
        1. The game plan
        2. Have some class!
      10. Time for action - store the essentials
        1. Start me up
        2. Going loopy
        3. The anatomy of a loop
        4. To nest is best
        5. Seeing is believing
      11. Time for action - create an area to store the grid
        1. Have a go hero - don't take my word for it!
        2. Build that grid
        3. What just happened grokking the code
        4. Now you're playing with power!
    12. 6. Game #2: Robot Repair Part 2
      1. From zero to game in one chapter
        1. Finding your center
      2. Time for action - center the game grid vertically
        1. What just happened?
      3. Time for action - center the game grid horizontally
        1. What just happened coding like a ninja
      4. Down to the nitty griddy
        1. Do the random card shuffle
      5. Time for action - prepare to build the deck
        1. Let's break some robots
      6. Time for action - build the deck
        1. What just happened dissecting the bits
      7. Time for action - modify the img argument
        1. What just happened?
        2. What exactly is "this"?
        3. Have a go hero - grokketh-thou Random.Range()?
        4. Random reigns supreme
        5. Second dragon down
        6. Time to totally flip
      8. Time for action - make the cards two-sided
      9. Time for action - build the card-flipping function
      10. Time for action - build the card-flipping function
        1. What just happened dissecting the flip
        2. Pumpkin eater
        3. What just happened?
        4. Stabby McDragonpoker rides again
        5. Game and match
      11. Time for action - ID the cards
        1. What just happened?
      12. Time for action - compare the IDs
        1. What just happened?
        2. On to the final boss
        3. Endgame
      13. Time for action - check for victory
        1. What just happened?
        2. Have a go hero - extra credit
        3. Endgame
        4. Bring. It. On.
    13. 7. Don't Be a Clock Blocker
      1. Apply pressure
      2. Time for action - prepare the clock script
      3. Time for more action prepare the clock text
      4. Still time for action change the clock text color
      5. Time for action - rides again create a font texture and material
      6. Time for action - what's with the tiny font?
        1. What just happened - was that seriously magic?
      7. Time for action - prepare the clock code
        1. What just happened that's a whole lotta nothing
      8. Time for action - create the countdown logic
      9. Time for action - display the time on-screen
        1. What just happened what about that terrifying code?
        2. Picture it
      10. Time for action - grab the picture clock graphics
        1. What just happened you can do that?
      11. Time for action - flex those GUI muscles
        1. What just happened how does it work?
        2. The incredible shrinking clock
        3. Keep your fork there's pie!
        4. Pop quiz how do we build it?
        5. How they did it
      12. Time for action - rig up the textures
      13. Time for action - write the pie chart Script
        1. What just happened?
      14. Time for action - commence operation pie clock
        1. What just happened explaining away the loose ends
      15. Time for action - positioning and scaling the clock
        1. Have a go hero - rock out with your clock out
      16. Unfinished business
    14. 8. Ticker Taker
      1. Welcome to Snoozeville
        1. Model behavior
      2. Time for action - explore the models
      3. Time for action - hands up!
        1. What just happened size matters
      4. Time for action - change the FBX import scale settings
      5. Time for action - make the Mesh Colliders convex
      6. Time for action - make the Hands and Tray follow the Mouse
        1. What just happened monkey see, monkey do
      7. Time for action - get your heart on
      8. Time for action - ditch the Ball and Paddle
        1. What just happened bypass the aorta
      9. Time for action - material witness
        1. What just happened understanding Materials
        2. Have a go hero - add Materials to the other models
      10. This Just In: This Game Blows
      11. Time for action - multiple erections
      12. Time for action - create a font texture
      13. Time for action - create the HeartBounce Script
        1. What just happened charting a collision course
      14. Time for action - tag the tray
      15. Time for action - tweak the bounce
        1. What just happened storing velocity
      16. Time for action - keeping track of the bounces
      17. Time for action - add the lose condition
        1. What just happened understanding the code
      18. Time for action - add the Play Again button
        1. What just happened?
        2. Ticker Taken
    15. 9. Game #3: The Break-Up
      1. Time for action - bombs away!
      2. Time for action - poke those particles
      3. Time for action - create a Spark Material
        1. Have a go hero - time to ignite your creative Spark
      4. Time for action - prefabulous
        1. What just happened what's a Prefab?
      5. Time for action - lights, camera, apartment
      6. Time for action - add the character
      7. Time for action - register the animations
      8. Time for action - script the character
        1. What just happened stepping through the "step" code
      9. Time for action - open the Pod Bay Door, Hal
      10. Time for action - collision-enable the Character
      11. Time for action - re-Prefab the Prefab
      12. Time for action - apocalypse now?
      13. Time for action - go boom
      14. Time for action - the point of impact
      15. Time for action - hook up the explosion
      16. Summary
    16. 10. Game #3: The Break-Up Part 2
      1. Time for action - amass some glass
      2. Time for action - create a Particle System
        1. What just happened getting smashed
      3. Time for action - make it edgier!
        1. What just happened I fall to pieces
      4. Time for action - contain the explosion
        1. What just happened duped?
      5. Time for action - let's get lazy
        1. What just happened FallingObject: The PuppetMaster
      6. Very variable?
      7. Terminal velocity is a myth bombs fall faster
        1. What just happened when Game Objects collide?
      8. Time for action - tag the objects
      9. Time for action - write the collision detection code
      10. Time for action - animation interrupts
        1. What just happened the impenetrable stare
      11. Time for action - add facial explosions
        1. What just happened raindrops keep 'sploding on my head
      12. Time for action - make some noise
      13. Time for action - add sounds to the FallingObjectScript
      14. What's the catch?
        1. Have a go hero - sound off
      15. Time for action - mix it up a bit
        1. Have a go hero - filling in the gaps
      16. Summary
    17. 11. Game #4: Shoot the Moon
      1. Time for action - duplicate your game project
      2. Time for action - space this sucker up a bit
      3. Time for action - enter the hero
      4. Time for action - it's a hit!
      5. Time for action - bring on the bad guys
      6. Time for action - do some housekeeping
      7. Time for action - fixing the fall
      8. Time for action - tweak the hero
        1. What just happened hooray for lazy!
      9. Time for action - give up the func
      10. Time for action - itchy trigger finger
      11. Time for action - futurize the bullet
      12. Time for action - building Halo
      13. Time for action - fire!
      14. Time for action - Code Do-Si-Do
        1. What just happened eat lead
      15. Time for action - the maaagic of aaaarguments
      16. Time for action - add the most important part of any spaceshooter
        1. Last year's model
        2. Have a go hero - filling in the empty space
      17. Summary
      18. More hospitality
    18. 12. Action!
      1. Open heart surgery
      2. Time for action - haul in the hallway
      3. Time for action - meet me at camera two
      4. Time for action - adjust the Main Camera
      5. Time for action - deck the halls
      6. Time for action - turn on the lights
      7. Time for action - set up the camera rig
      8. Time for action - animate the bouncer
        1. What just happened red and raging
      9. Time for action - I like to move it move it
        1. Have a go hero - bounce your brains out
      10. Time for action - animate the runner
        1. What just happened holy hospital rampage, Batman!
      11. Time for action - how to "handle" Nurse Slipperfoot
      12. Time for action - you spin me right round
        1. Have a go hero - give Robo-Nurse a soul
        2. Have a go hero - use your new-found powers for good
      13. Time for action - deploy your game
        1. Time to grow
        2. Beyond the book
    19. A. References
      1. Online resources
      2. Offline resources
      3. Free development tools
        1. Graphics
        2. Sound
      4. Content sites
      5. Game Portals
    20. Index

Product information

  • Title: Unity 3D Game Development by Example
  • Author(s): Ryan Henson Creighton
  • Release date: September 2010
  • Publisher(s): Packt Publishing
  • ISBN: 9781849690546