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

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

Credits

About the Author

About the Reviewers

www.PacktPub.com

Preface

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

Kongregate

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!

Summary

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

Toy or story

Redefining the sky

Summary

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

Summary

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

Ding!

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

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

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

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

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

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

Summary

C# addendum

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

Summary

C# Addendum

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

Summary

C# Addendum

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

Codesplosion

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

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

Summary

C# addendum

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

Appendix

Appendix

Appendix

Appendix

Appendix

Appendix

Index