Free Sample
+ Collection

Unity 4.x Cookbook

Matt Smith, Chico Queiroz

Maximize the potential of Unity 4 with this wide-ranging book. Your games will look better, play more realistically, and communicate with more devices through applying these fully explanatory recipes.
RRP $29.99
RRP $49.99
Print + eBook

Want this title & more?

$12.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 139781849690423
Paperback386 pages

About This Book

  • A wide range of topics are covered, ranging in complexity, offering something for every Unity 4 game developer
  • Every recipe provides step-by-step instructions, followed by an explanation of how it all works, and alternative approaches or refinements
  • Book developed with the latest version of Unity (4.x)

Who This Book Is For

From beginners to advanced users, from artists to coders, this book is for you and everyone in your team!

This book is for anyone who wants to explore a wide range of Unity scripting and multimedia features and to find ready to use solutions to many game features. Programmers can explore multimedia features, and multimedia developers can try their hand at scripting.

Table of Contents

Chapter 1: Getting Started with Unity 4.x
Installing Unity 4.x
Setting your preferences
Understanding and optimizing the User Interface
Saving assets created in Unity as Prefabs
Discovering Unity's content
Importing your own content
Importing Unity packages into your project
Importing custom packages into your project
Exporting custom packages from your project
Adding custom packages to Unity's quick list
Using the Project browser
Chapter 2: Using Cameras
Creating a picture-in-picture effect
Switching between multiple cameras
Customizing the lens flare effect
Making textures from screen content
Zooming a telescopic camera
Making an inspect camera
Creating particle effects using Shuriken
Displaying a mini-map
Chapter 3: Creating Maps and Materials
Creating a reflective material
Creating a self-illuminated material
Creating specular texture maps
Creating transparency texture maps
Using cookie textures to simulate a cloudy outdoor
Creating a color selection dialog
Combining textures in real time through the GUI
Highlighting materials at mouse over
Animating textures by looping through array of materials (for example, simulated video)
Disabling culling for a material
Chapter 4: Creating GUIs
Displaying a digital clock
Displaying an analogue clock
Displaying a compass to show player direction
Displaying a radar to indicate relative locations of objects
Displaying images for corresponding integers
Displaying images for corresponding floats and ranges
Displaying a digital countdown timer
Displaying a countdown timer graphically (5, 4, 3, 2, 1 – blast off)
Displaying a countdown timer graphically as a pie-chart style clock
Creating a message that fades away
Displaying inventory texts for single object pickups
Displaying inventory icons for single object pickups
Managing inventories with a general purpose PickUp class
Controlling the scrollbar with the mouse wheel
Implementing custom mouse cursor icons
Chapter 5: Controlling Animations
Configuring a character's Avatar and Idle animation
Moving your character with Root Motion and Blend Trees
Mixing animations with Layers and Masks
Overriding Root Motion via script
Adding rigid props to animated characters
Making an animated character throw an object
Applying ragdoll physics to a character
Rotating the character's torso to aim
Chapter 6: Playing and Manipulating Sounds
Matching audio pitch to animation speed
Adding customizable volume controls
Simulating a tunnel environment with Reverb Zones
Preventing the AudioClip from restarting if already playing
Waiting for audio to finish before auto-destructing an object
Making a dynamic soundtrack
Chapter 7: Working with External Resource Files and Devices
Loading external resource files – by Unity Default Resources
Loading external resource files – by manually storing files in Unity's Resources folder
Loading external resource files – by downloading files from the Internet
Saving and loading player data – using static properties
Saving and loading player data – using PlayerPrefs
Saving screenshots from the game
Control characters in Unity with the Microsoft Kinect using the Zigfu samples
Animating your own characters with the Microsoft Kinect controller
Homemade mocap by storing movements from the Microsoft Kinect controller
Setting up a leaderboard using PHP/MySQL
Chapter 8: Working with External Text Files and XML Data
Loading external text files using the TextAsset public variable
Loading external text files using C# file streams
Saving external text files with C# file streams
Loading and parsing external XML files
Creating XML text data manually using XMLWriter
Creating XML text data automatically through serialization
Creating XML text files – saving XML directly to text files with XMLDocument.Save()
Chapter 9: Managing Object States and Controlling Their Movements
Controlling cube movement through player controls
Controlling object look-at behavior
Controlling object-to-object movements (seek, flee, follow at a distance)
Controlling object group movement through flocking
Firing objects by instantiation with forward velocity
Finding a random spawn point
Finding the nearest spawn point
Following waypoints in a sequence
Managing object behavior with states
Managing complex object behavior with the state pattern
Chapter 10: Improving Games with Extra Features and Optimization
Pausing the game
Implementing slow motion
Implementing 3D stereography with polarized projection
Preventing your game from running on unknown servers
Identifying performance "bottlenecks" with code profiling
Reducing the number of objects by destroying objects at a "death" time
Reducing the number of enabled objects by disabling objects whenever possible
Improving efficiency with delegates and events (and avoiding SendMessage!)
Executing methods regularly but independent of frame rate with coroutines
Spreading long computations over several frames with coroutines
Caching, rather than component lookups and "reflection" over objects
Chapter 11: Taking Advantage of Unity Pro
Dynamically focusing objects with Depth of Field
Creating a rearview mirror
Playing videos inside a scene
Simulating underwater ambience with audio filters
Loading and playing external movie files

What You Will Learn

  • Enhance your character`s animation in real time using Unity`s new Mecanim system
  • Measure and control time, including pausing the game, displaying clocks and countdown timers, and even implementing “bullet time” effects
  • Work with cameras, images, and the Shuriken practical system, to create mini-maps, control zooming, and depth of field, and switch between cameras
  • Define materials for reflections, transparency, specular and self-illumination of materials, and cloudy outdoor effects
  • Use artificial intelligence techniques to make non-player character objects seek, follow, flee each other, or follow a waypoint sequence, and even flock together like a herd of animals
  • Make your game communicate with Microsoft Kinect cameras, for control of game characters, and even to record your own motion capture
  • Improve GUIS with real-time radars, custom mouse cursors, analogue and digital clocks, color section dialogs, mouse over material highlighting, graphical power-bars, and a flexible inventory class
  • Save and load text, XML, or media assets from local or remote sources, and communicate with websites and their databases to create online scoreboards

In Detail

Covering the latest version (Unity 4) of this established game engine, the Unity 4.x Cookbook explores a wide range of 3D, animation, multimedia, and scripting game features.

The power of Unity 4 is demonstrated through the 10 chapters covering many of this game engine’s features.

"Unity 4.x Cookbook" helps you learn how to make the most of the powerful but easy-to-use Unity 4 game engine.

Every Unity game developer is different. Some come from a multimedia background, some are new to game development, and some are transferring from other engines. Whatever your background, with the breadth and depth of topics covered you should find new features and techniques to enhance your next game.

This book offers detailed, easy-to-follow, step-by-step recipes helping you master a wide range of Unity game features.

Chapters are provided focusing on the basics; audio, cameras, images, materials and animations, GUIs, external resources and devices, directional and artificial intelligence character control, and performance optimization.

"Unity 4.x Cookbook" provides a collection of ideas and resources that should offer new and useful techniques for every Unity game developer to enhance their next game.


Read More

Recommended for You

Learning Unity 2D Game Development by Example
$ 26.99
Unity 4.x Game Development by Example: Beginner's Guide
$ 26.99
Mastering Unity 4 Scripting [Video]
$ 25.50
Getting Started with Unity 4 Scripting [Video]
$ 25.50