You are previewing Sams Teach Yourself Unity® Game Development in 24 Hours, Second Edition.
O'Reilly logo
Sams Teach Yourself Unity® Game Development in 24 Hours, Second Edition

Book Description

In just 24 lessons of one hour or less, Sams Teach Yourself Unity Game Development in 24 Hours will help you master the Unity 5 game engine at the heart of Hearthstone: Heroes of Warcraft, Kerbal Space Program, and many other sizzling-hot games!

This book’s straightforward, step-by-step approach teaches you everything from the absolute basics through sophisticated game physics, animation, and mobile device deployment techniques. Every lesson builds on what you’ve already learned, giving you a rock-solid foundation for real-world success.

  • Step-by-step instructions carefully walk you through the most common Unity game development tasks.

  • Practical, hands-on examples show you how to apply what you learn.

  • Quizzes and exercises help you test your knowledge and stretch your skills.

  • Notes and tips point out shortcuts and solutions.

  • Learn how to…

  • Get up and running fast with the Unity 5 game engine and editor

  • Work efficiently with Unity’s graphical asset pipeline

  • Make the most of lights and cameras

  • Sculpt stunning worlds with Unity’s terrain and environmental tools

  • Script tasks ranging from capturing input to building complex behaviors

  • Quickly create repeatable, reusable game objects with prefabs

  • Implement easy, intuitive game user interfaces

  • Control players through built-in and custom character controllers

  • Build realistic physical and trigger collisions

  • Leverage the full power of Unity’s Mecanim animation system

  • Integrate complex audio into your games

  • Use mobile device accelerometers and multi-touch displays

  • Modify desktop games for mobile platforms

  • Apply the “finishing touches” and deploy your games

  • Table of Contents

    1. About This E-Book
    2. Title Page
    3. Copyright Page
    4. Praise for Sams Teach Yourself Unity Game Development in 24 Hours, Second Edition
    5. Contents at a Glance
    6. Table of Contents
    7. Preface
      1. Who Should Read This Book
      2. How This Book Is Organized and What It Covers
      3. Companion Files
    8. About the Authors
    9. Dedication
    10. Acknowledgments
    11. We Want to Hear from You
    12. Reader Services
    13. Hour 1. Introduction to Unity
      1. Installing Unity
        1. Downloading and Installing Unity
      2. Getting to Know the Unity Editor
        1. The Project Dialog
        2. The Unity Interface
        3. The Project View
        4. The Hierarchy View
        5. The Inspector View
        6. The Scene View
        7. The Game View
        8. Honorable Mention: The Toolbar
      3. Navigating the Unity Scene View
        1. The Hand Tool
        2. Flythrough Mode
      4. Summary
      5. Q&A
      6. Workshop
        1. Quiz
        2. Answers
      7. Exercise
    14. Hour 2. Game Objects
      1. Dimensions and Coordinate Systems
        1. Putting the D in 3D
        2. Using Coordinate Systems
        3. World Versus Local Coordinates
      2. Game Objects
      3. Transforms
        1. Translation
        2. Rotation
        3. Scaling
        4. Hazards of Transformations
        5. Transforms and Nested Objects
      4. Summary
      5. Q&A
      6. Workshop
        1. Quiz
        2. Answers
      7. Exercise
    15. Hour 3. Models, Materials, and Textures
      1. The Basics of Models
        1. Built-In 3D Objects
        2. Importing Models
        3. Models and the Asset Store
      2. Textures, Shaders, and Materials
        1. Textures
        2. Shaders
        3. Materials
        4. Shaders Revisited
      3. Summary
      4. Q&A
      5. Workshop
        1. Quiz
        2. Answers
      6. Exercise
    16. Hour 4. Terrain
      1. Terrain Generation
        1. Adding Terrain to Your Project
        2. Heightmap Sculpting
        3. Unity Terrain Sculpting Tools
      2. Terrain Textures
        1. Importing Terrain Assets
        2. Texturing Terrain
      3. Summary
      4. Q&A
      5. Workshop
        1. Quiz
        2. Answers
      6. Exercise
    17. Hour 5. Environments
      1. Generating Trees and Grass
        1. Painting Trees
        2. Painting Grass
        3. Terrain Settings
      2. Environment Effects
        1. Skyboxes
        2. Fog
        3. Lens Flares
        4. Water
      3. Character Controllers
        1. Adding a Character Controller
        2. Fixing Your World
      4. Summary
      5. Q&A
      6. Workshop
        1. Quiz
        2. Answers
      7. Exercise
    18. Hour 6. Lights and Cameras
      1. Lights
        1. Point Lights
        2. Spotlights
        3. Directional Lights
        4. Creating Lights Out of Objects
        5. Halos
        6. Cookies
      2. Cameras
        1. Anatomy of a Camera
        2. Multiple Cameras
        3. Split Screen and Picture in Picture
      3. Layers
        1. Working with Layers
        2. Using Layers
      4. Summary
      5. Q&A
      6. Workshop
        1. Quiz
        2. Answers
      7. Exercise
    19. Hour 7. Game 1: Amazing Racer
      1. Design
        1. The Concept
        2. The Rules
        3. The Requirements
      2. Creating the Game World
        1. Sculpting the World
        2. Adding the Environment
        3. The Character Controller
      3. Gamification
        1. Adding Game Control Objects
        2. Adding Scripts
        3. Connecting the Scripts Together
      4. Playtesting
      5. Summary
      6. Q&A
      7. Workshop
        1. Quiz
        2. Answers
      8. Exercise
    20. Hour 8. Scripting—Part 1
      1. Scripts
        1. Creating Scripts
        2. Attaching a Script
        3. Anatomy of a Basic Script
        4. The Using Section
        5. The Class Declaration Section
        6. The Class Contents
      2. Variables
        1. Creating Variables
        2. Variable Scope
        3. Public and Private
      3. Operators
        1. Arithmetic Operators
        2. Assignment Operators
        3. Equality Operators
        4. Logical Operators
      4. Conditionals
        1. The if Statement
        2. The if / else Statement
        3. The if / else if Statement
      5. Iteration
        1. The while Loop
        2. The for Loop
      6. Summary
      7. Q&A
      8. Workshop
        1. Quiz
        2. Answers
      9. Exercise
    21. Hour 9. Scripting—Part 2
      1. Methods
        1. Anatomy of a Method
        2. Writing Methods
        3. Using Methods
      2. Input
        1. Input Basics
        2. Input Scripting
        3. Specific Key Input
        4. Mouse Input
      3. Accessing Local Components
        1. Using GetComponent
        2. Accessing The Transform
      4. Accessing Other Objects
        1. Finding Other Objects
        2. Modifying Object Components
      5. Summary
      6. Q&A
      7. Workshop
        1. Quiz
        2. Answers
      8. Exercise
    22. Hour 10. Collision
      1. Rigidbodies
      2. Collision
        1. Colliders
        2. Physics Materials
      3. Triggers
      4. Raycasting
      5. Summary
      6. Q&A
      7. Workshop
        1. Quiz
        2. Answers
      8. Exercise
    23. Hour 11. Game 2: Chaos Ball
      1. Design
        1. The Concept
        2. The Rules
        3. The Requirements
      2. The Arena
        1. Creating the Arena
        2. Texturing
        3. Super Bouncy Material
        4. Finish the Arena
      3. Game Entities
        1. The Player
        2. Chaos Balls
        3. The Colored Balls
      4. The Control Objects
        1. The Goals
        2. The Game Controller
      5. Improving the Game
      6. Summary
      7. Q&A
      8. Workshop
        1. Quiz
        2. Answers
      9. Exercise
    24. Hour 12. Prefabs
      1. Prefab Basics
        1. Prefab Terminology
        2. Prefab Structure
      2. Working with Prefabs
        1. Adding a Prefab Instance to a Scene
        2. Inheritance
        3. Instantiating Prefabs Through Code
      3. Summary
      4. Q&A
      5. Workshop
        1. Quiz
        2. Answers
      6. Exercise
    25. Hour 13. 2D Games Tools
      1. The Basics of 2D Games
        1. The 2D Scene View
      2. Orthographic Cameras
      3. Adding Sprites
        1. Importing Sprites
        2. Sprite Mode
        3. Imported Sprite Sizes
      4. Draw Order
        1. Sorting Layer
        2. Order in Layer
      5. 2D Physics
        1. Rigidbody 2D
        2. 2D Colliders
      6. Summary
      7. Q&A
      8. Workshop
        1. Quiz
        2. Answers
      9. Exercise
    26. Hour 14. User Interfaces
      1. Basic UI Principles
      2. The Canvas
        1. The Rect Transform
        2. Anchors
        3. Additional Canvas Components
      3. UI Elements
        1. Images
        2. Text
        3. Buttons
      4. Canvas Render Modes
        1. Screen-Space Overlay
        2. Screen-Space Camera
        3. World Space
      5. Summary
      6. Q&A
      7. Workshop
        1. Quiz
        2. Answers
      8. Exercise
    27. Hour 15. Game 3: Captain Blaster
      1. Design
        1. The Concept
        2. The Rules
        3. The Requirements
      2. The World
        1. The Camera
        2. The Background
        3. Game Entities
        4. The Player
        5. The Meteors
        6. The Bullets
        7. The Triggers
        8. The UI
      3. Controls
        1. The Game Control
        2. The Meteor Script
        3. The Meteor Spawn
        4. The DestroyOnTrigger Script
        5. The ShipControl Script
        6. The Bullet Script
      4. Improvements
      5. Summary
      6. Q&A
      7. Workshop
        1. Quiz
        2. Answers
      8. Exercise
    28. Hour 16. Particle Systems
      1. Particle Systems
        1. Particles
        2. Unity Particle Systems
        3. Particle System Controls
      2. Particle System Modules
        1. Default Module
        2. Emission Module
        3. Shape Module
        4. Velocity over Lifetime Module
        5. Limit Velocity over Lifetime Module
        6. Force over Lifetime Module
        7. Color over Lifetime Module
        8. Color by Speed Module
        9. Size over Lifetime Module
        10. Size by Speed Module
        11. Rotation over Lifetime Module
        12. Rotation by Speed Module
        13. External Forces Module
        14. Collision Module
        15. Sub Emitter Module
        16. Texture Sheet Module
        17. Renderer Module
      3. The Curve Editor
      4. Summary
      5. Q&A
      6. Workshop
        1. Quiz
        2. Answers
      7. Exercise
    29. Hour 17. Animations
      1. Animation Basics
        1. The Rig
        2. The Animation
      2. Animation Types
        1. 2D Animations
        2. Creating the Animation
      3. Animation Tools
        1. Animation Window
        2. Creating a New Animation
        3. Record Mode
        4. The Curves Editor
      4. Summary
      5. Q&A
      6. Workshop
        1. Quiz
        2. Answers
      7. Exercise
    30. Hour 18. Animators
      1. Animator Basics
        1. Rigging Revisited
        2. Importing a Model
      2. Configuring Your Assets
        1. Rig Preparation
        2. Animation Preparation
      3. Creating an Animator
        1. The Animator View
        2. The Idle Animation
        3. Parameters
        4. States and Blend Trees
        5. Transitions
      4. Scripting Animators
      5. Summary
      6. Q&A
      7. Workshop
        1. Quiz
        2. Answers
      8. Exercise
    31. Hour 19. Game 4: Gauntlet Runner
      1. Design
        1. The Concept
        2. The Rules
        3. The Requirements
      2. The World
        1. The Scene
        2. The Ground
        3. Scrolling the Ground
      3. The Entities
        1. The Power Ups
        2. The Obstacles
        3. The Trigger Zone
        4. The Player
      4. The Controls
        1. Trigger Zone Script
        2. The Game Control Script
        3. The Player Script
        4. The Move Script
        5. The Spawn Script
        6. Putting It All Together
      5. Room for Improvement
      6. Summary
      7. Q&A
      8. Workshop
        1. Quiz
        2. Answers
      9. Exercise
    32. Hour 20. Audio
      1. Audio Basics
        1. Parts of Audio
        2. 2D and 3D Audio
      2. Audio Sources
        1. Importing Audio Clips
        2. Testing Audio in the Scene View
        3. 3D Audio
        4. 2D Audio
      3. Audio Scripting
        1. Starting and Stopping Audio
        2. Changing Audio Clips
      4. Summary
      5. Q&A
      6. Workshop
        1. Quiz
        2. Answers
      7. Exercise
    33. Hour 21. Mobile Development
      1. Preparing for Mobile
        1. Setting Up Your Environment
        2. The Unity Remote
      2. Accelerometers
        1. Designing for the Accelerometer
        2. Using the Accelerometer
        3. Multi-Touch Input
      3. Summary
      4. Q&A
      5. Workshop
        1. Quiz
        2. Answers
      6. Exercise
    34. Hour 22. Game Revisions
      1. Cross-Platform Input
        1. Virtual Controls
        2. Converting Projects to Mobile
      2. Amazing Racer
        1. Using Tilt Control
        2. Using a Touch Joystick
        3. Fixing the Disappearing Joystick
      3. Chaos Ball
      4. Captain Blaster
      5. Gauntlet Runner
      6. Summary
      7. Q&A
      8. Workshop
        1. Quiz
        2. Answers
      9. Exercise
    35. Hour 23. Polish and Deploy
      1. Managing Scenes
        1. Establishing Scene Order
        2. Switching Scenes
      2. Persisting Data and Objects
        1. Keeping Objects
        2. Saving Data
      3. Unity Player Settings
        1. Cross-Platform Settings
        2. Per-Platform Settings
      4. Building Your Game
        1. Build Settings
        2. Game Settings
      5. Summary
      6. Q&A
      7. Workshop
        1. Quiz
        2. Answers
      8. Exercise
    36. Hour 24. Wrap Up
      1. Accomplishments
        1. Your 19 Hours of Learning
        2. Four Complete Games
        3. Over 50 Scenes
      2. Where to Go from Here
        1. Make Games
        2. Work with People
        3. Write About It
      3. Resources Available to You
      4. Summary
      5. Q&A
      6. Workshop
        1. Quiz
        2. Answers
      7. Exercise
    37. Index
    38. Code Snippets