Free Sample
+ Collection

Unity 4.x Game Development by Example: Beginner's Guide

Beginner's Guide
Ryan Henson Creighton

A seat-of-your-pants manual for building fun, groovy little games quickly with Unity 4.x
RRP $26.99
RRP $44.99
Print + eBook

Want this title & more?

$16.99 p/month

Subscribe to PacktLib

Enjoy full and instant access to over 2000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

Book Details

ISBN 139781849695268
Paperback572 pages

About This Book

  • Learn the basics of the Unity 3D game engine by building five small, functional game projects
  • Explore simplification and iteration techniques that will make you more successful as a game developer
  • Take Unity for a spin with a refreshingly humorous approach to technical manuals

Who This Book Is For

If you’ve ever wanted to enter the world of independent game development but have no prior knowledge of programming or game development, then this is the book for you. Game developers transitioning from other tools like GameMaker and Flash will find this a useful tool to get them up to speed on the Unity engine, as will anyone who has never handled the Unity engine before.

Table of Contents

Chapter 1: That's One Fancy Hammer!
Introducing Unity 3D
The engine, the tool, and the all-weather tires
Unity takes over the world
Why choose Unity?
Why burn this book and run away screaming?
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?
Completely hammered
Should we try to build FusionFall?
Another option
I bent my Wooglie
Unity Technologies – "Made with Unity" page
The iOS App Store
Walk before you can run (or double jump)
There's no such thing as "finished"
Stop! Hammer time
The wonders of technology!
The Scene window
Don't stop there – live a little!
Chapter 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
Heads up!
Artillery Live!
The mechanic that launched a thousand games
Toy or story
Redefining the sky
Chapter 3: Game #1 – Ticker Taker
Kick up a new Unity project
'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
A ball by any other name
Time for action – rename the Ball
Origin story
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
Keeping yourself in the dark
Time for action – add a light
Time for action – move and rotate the light
Are you a luminary?
Time for action – test your game
Let's get physical
Add physics to your game
Understanding the gravity of the situation
More bounce to the ounce
Time for action – make the Ball bouncy
Chapter 4: Code Comfort
What is code?
Time for action – write your first Unity Script
A leap of faith
Lick it and stick it
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 re-appear
Time for action – journey to the Unity Script Reference
The Renderer class
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
A capital idea
Animating with code
Time for action – animate the Paddle
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 – listen to 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
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 – re-visit the Unity Language Reference
Our work here is done
Time for action – add the sample code to your Script
One final tweak
Educated guesses
Right on target
Keep it up
C# Addendum
Chapter 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
Time for action – create a button UI control
Want font?
Cover your assets
Time for action – nix the mip-mapping
Front and center
Time for action – center the button
The waiting game
The easiest button to button
To the game!
Time for action – add both scenes to 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
A matter of great import
Building a better bucket
How big is your locker?
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
Build that grid
Now you're playing with power!
C# addendum
Chapter 6: Game #2 – Robot Repair Part 2
From zero to game in one chapter
Finding your center
Time for action – centering the game grid vertically
Time for action – centering the game grid horizontally
Down to the nitty griddy
Time for action – preparing to build the deck
Time for action – building the deck
Time for action – modifying the img argument
What exactly is "this"?
Random reigns supreme
Second dragon down
Time to totally flip
Time for action – making the cards two-sided
Time for action – building the card-flipping function
Time for action – building the card-flipping function
Pumpkin eater
Stabby McDragonpoker rides again
Game and match
Time for action – ID the cards
Time for action – comparing the IDs
On to the final boss
Time for action – checking for victory
Bring. It. On.
C# Addendum
Chapter 7: Don't Be a Clock Blocker
Apply pressure
Time for action – preparing the Clock Script
Time for more action – preparing the clock text
Still time for action – changing the clock text color
Time for action rides again – creating Font Texture and Material
Time for action – what's with the tiny font?
Time for action – preparing the clock code
Time for action – creating the countdown logic
Time for action – displaying the time on-screen
Picture it
Time for action – grabbing the picture clock graphics
Time for action – Flex those GUI muscles
The incredible shrinking clock
Keep your fork – there's pie!
How they did it
Time for action – rigging up the textures
Time for action – writing the pie chart script
Time for action – commencing operation pie clock
Time for action – positioning and scaling the clock
Unfinished business
C# Addendum
Chapter 8: Hearty Har Har
Welcome to Snoozeville
Model behavior
Time for action – exploring the models
Time for action – hands up!
Time for action – changing the FBX import scale settings
Time for action – making the mesh colliders convex
Time for action – making the hands and tray follow the mouse
Time for action – getting your heart on
Time for action – ditching the Ball and Paddle
Time for action – material witness
This just in – this game blows
Time for action – multiple erections
Time for action – creating a font texture
Time for action – create the HeartBounce script
Time for action – tagging the tray
Time for action – tweaking the bounce
Time for action – keeping track of the bounces
Time for action – adding the lose condition
Time for action – adding the Play Again button
Ticker taken
C# Addendum
Chapter 9: Game #3 – The Break-Up
Time for action – bombs away!
Time for action – poke those particles
Time for action – creating a spark material
Time for action – prefabulous
Time for action – lights, camera, and apartment
Time for action – adding the character
Time for action – registering the animations
Time for action – scripting the character
Time for action – open the pod bay door, Hal
Time for action – collision-enable the character
Time for action – apocalypse now?
Time for action – go boom
Time for action – kill kill murder die
Time for action – the point of impact
Time for action – hook up the explosion
C# addendum
Chapter 10: Game #3 – The Break-Up Part 2
Time for action – amass some glass
Time for action – create a particle system
Time for action – make it edgier!
Time for action – contain the explosion
Time for action – let's get lazy
Very variable?
Terminal velocity is a myth – bombs fall faster
Time for action – tag the objects
Time for action – write the collision detection code
Time for action – animation interrupts
Time for action – add facial explosions
Time for action – make some noise
Time for action – add sounds to FallingObject
Silent 'Splosion
What's the catch?
Time for action – mix it up a bit
C# Addendum
Chapter 11: Game #4 – Shoot the Moon
Time for action – duplicate your game project
Time for action – space the shooter 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
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
Time for action – the maaagic of aaaarguments
Time for action – add the most important part of any space shooter
C# Addendum
Chapter 12: Game #5 – Kisses 'n' Hugs
Computers that think
Time for action – haul in the hallway
Time for action – hash it out
One Script to rule them all
Time for action – it's hip to be square
Squaring the Square
Time for action – now you see it...
Family values
Time for action – X marks the spot
Time for action – boy O boy
Time for action – bottoming out
Here comes the drop
Time for action – +9 accuracy
Time for action – solve for X
Time for action – it takes two to Tic Tac Toe
Time for action – designer to player. Come in, player.
Slowly building to a climax
Read after thinking
On deaf ears
Time for action – pretty maids all in a row
Winner is coming
Need-to-know basis
Need-to-know basis
Clean-up on aisle code
Shave and a haircut
Time for action – check for a win
Sore loser
Time for action – notify the winner
Time for action – you win. Now what?
Nice moves
Time for action – the final bug
All done but for the shouting
C# addendum
Chapter 13: AI Programming and World Domination
Take it away, computer
Time for action – add computer control
Herpa derp derp
Unpacking the code
Time for action – code consolidation
Tic Tac Toe at the speed of light
Sore loser
Click-spamming for fun and profit
Artificial stupidity
Time for action – winning is everything
It's a trap!
The leftovers
Time for action – pseu pseu pseudocode
Time for action – begin at the end
Time for action – the final four
Code one, get one free
The actual intelligence behind artificial intelligence
Time for action – score!
Time for action – to catch a competitor
Time for action – programming fallibility
C# addendum
Chapter 14: Action!
Open heart surgery
Time for action – haul in the hallway
Time for action – meet me at camera two
Time for action – adjust 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
Time for action – I like to move it move it
Time for action – animate the runner
Time for action – how to "handle" Nurse Slipperfoot
Time for action – you spin me right round
Time for action – deploy your game
Time to grow
Beyond the book

What You Will Learn

  • Explore the basic development flow of the Unity 3D game engine
  • Understand fundamental programming concepts in both Javascript and C#
  • Develop five different games from inception to completion
  • Discover the secrets new game developers use to be successful when they're just starting out
  • Grasp the nuances of Unity's immediate-mode GUI
  • Completely re-skin a game for fun and (potentially) profit
  • Lengthen gameplay by learning how to use random numbers
  • Explore the process of writing Artificial Intelligence from scratch

In Detail

Unity is one of the biggest game engines in the world, providing the user with a range of important tools that they need to bring their ideas into reality. Beginner game developers are optimistic, passionate, and ambitious, but that ambition can be dangerous! Too often, budding indie developers and hobbyists bite off more than they can chew. Games like Angry Birds, Cut the Rope, and Fruit Ninja are 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, starting today.

This book teaches you the ins and outs of the unique Unity game engine interface. Clear and concise code examples written in both Unity Javascript and C# take you through the step-by-step process of building five small, functional games. With this understanding you can start making your own mark on the game industry!

With absolutely no programming or game development experience, you will learn how to build five simple games in Unity by following step-by-step instructions, peppered with amusing analogies and anecdotes from an experienced indie developer. Following a primer on simplifying your game ideas to that single “something” that keeps players coming back for more, dive into the Unity game engine by creating a simple bat-and-ball game. From there, you'll build a complete memory game using only the Unity GUI system. After building a 2.5D mouse avoider game, you'll learn how to re-skin the project to completely change the game's theme. Incorporating everything you've learned, you'll return to complete the bat-and-ball game by adding scoring, replay flow, sound effects, and animations. Finally, in the new bonus chapter, you'll program some simple AI (Artificial Intelligence) for a tic tac toe game.

"Unity 4.x Game Development by Example" is a fun and light-hearted exploration of one of the most powerful game engines on the market today. Find out what all the fuss is about by getting up to speed using this book!


Read More