Achieve mesmerizing game experiences using the latest Unity 2021 features by following a practical approach to building professional games

Key Features

  • Unleash the capabilities of C# scripting to create UIs, graphics, game AI agents and more
  • Explore Unity's latest tools, including Universal Render Pipeline, Shader Graph, UI Toolkit, Visual Scripting, and VFX graph, to enhance graphics and animation
  • Build an AR experience using Unity's AR Foundation

Book Description

Unity is a comprehensive yet simple suite of tools for developing video games. You can use Unity to not only create video games, but also AR/VR experiences, complex simulations, real-time realistic rendering, films, and practical games for training and education. With this book, you will get to grips with creating a full game from the ground up, building it step-by-step and applying your knowledge as you progress.

Complete with hands-on tutorials and projects, this easy-to-follow guide will teach you how to develop the game using several Unity tools. As you advance, you will learn how to use the Unity engine, create simple scripts using C#, integrate graphics, sound, and animations, and manipulate physics to create interesting mechanics for your game. You'll be able to apply all the knowledge that you gain to a real-world game. Later chapters will show you how to code a simple AI agent to challenge the user and use profiling tools to ensure that the code runs efficiently. Finally, you'll work with Unity's AR tools to create AR experiences for 3D apps and games.

By the end of this Unity book, you will have created a complete game and built a solid foundation in using a wide variety of Unity tools.

What you will learn

  • Explore both C# and Visual Scripting tools to customize various aspects of a game, such as physics, gameplay, and the UI
  • Program rich shaders and effects using Unity's new Shader Graph and Universal Render Pipeline
  • Implement postprocessing to improve graphics quality with full-screen effects
  • Create rich particle systems for your Unity games from scratch using VFX Graph and Shuriken
  • Add animations to your game using the Animator, Cinemachine, and Timeline
  • Use the brand new UI Toolkit package to create user interfaces
  • Implement game AI to control character behavior

Who this book is for

This Unity engine book is for game developers looking to migrate to the Unity game engine. If you are a developer with some exposure to Unity, this book will help you explore its latest features. Prior experience with C# programming is required to get the most out of this Unity game development book.

Table of Contents

  1. Hands-On Unity 2021 Game Development Second Edition
  2. Contributors
  3. About the author
  4. About the reviewers
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Download the color images
    6. Conventions used
    7. Get in touch
    8. Share Your Thoughts
  6. Section 1 – Our First Level
  7. Chapter 1: Designing a Game from Scratch
    1. Game concept
    2. Game idea
    3. Input controls
    4. Winning and losing
    5. Game characters
    6. Hero
    7. Enemies
    8. Gameplay
    9. Game-world layout
    10. Starting condition
    11. Ending condition
    12. Point system
    13. HUD
    14. The difficulty balance
    15. Difficulty balance questions
    16. Implementation plan
    17. Documentation
    18. Game Design Document (GDD)
    19. GDD formats
    20. GDD creation tools
    21. Elevator pitch
    22. High concept
    23. Tips for creating GDDs
    24. Summary
  8. Chapter 2: Setting Up Unity
    1. Why use a game engine such as Unity?
    2. Past and present industry insight
    3. Game engines
    4. Benefits of using Unity
    5. Installing Unity
    6. Unity Technical Requirements
    7. Unity installs
    8. Installing Unity with Unity Hub
    9. Creating projects
    10. Creating a project
    11. Project structure
    12. Summary
  9. Chapter 3: Working with Scenes and Game Objects
    1. Manipulating scenes
    2. The purpose of a scene
    3. The Scene View
    4. Creating our first GameObject
    5. Navigating the Scene View
    6. Manipulating GameObjects
    7. GameObjects and components
    8. Understanding components
    9. Manipulating components
    10. Object hierarchies
    11. Parenting objects
    12. Possible uses
    13. Prefabs
    14. Creating Prefabs
    15. Prefab-instance relationship
    16. Prefab variants
    17. Saving scenes and projects
    18. Saving our changes
    19. Project structure
    20. Summary
  10. Chapter 4: Grayboxing with Terrain and ProBuilder
    1. Creating a Landscape with Terrain
    2. Discussing Height Maps
    3. Creating and configuring Height Maps
    4. Authoring Height Maps
    5. Adding Height Map details
    6. Creating Shapes with ProBuilder
    7. Installing ProBuilder
    8. Creating a Shape
    9. Manipulating the mesh
    10. Adding details
    11. Summary
  11. Chapter 5: Importing and Integrating Assets
    1. Importing assets
    2. Importing assets from the internet
    3. Importing assets from the Asset Store
    4. Integrating assets
    5. Integrating terrain textures
    6. Integrating meshes
    7. Integrating textures
    8. Configuring assets
    9. Configuring meshes
    10. Configuring textures
    11. Assembling the scene
    12. Summary
  12. Section 2 – Improving Graphics and Sound
  13. Chapter 6: Materials and Effects with URP and Shader Graph
    1. Introducing shaders
    2. Shader pipeline
    3. The Render Pipeline and URP
    4. URP's Built-in Shaders
    5. Creating Shaders with Shader Graph
    6. Creating our first Shader Graph
    7. Using textures
    8. Combining Textures
    9. Applying transparency
    10. Creating Vertex Effects
    11. Summary
  14. Chapter 7: Visual Effects with Particle Systems and Visual Effect Graph
    1. Introduction to particle systems
    2. Creating a basic particle system
    3. Using advanced modules
    4. Creating fluid simulations
    5. Creating a waterfall effect
    6. Creating a bonfire effect
    7. Creating complex simulations with Visual Effect Graph
    8. Installing Visual Effect Graph
    9. Creating and analyzing a Visual Effect Graph
    10. Creating a rain effect
    11. Summary
  15. Chapter 8: Lighting Using the Universal Render Pipeline
    1. Applying lighting
    2. Discussing lighting methods
    3. Configuring ambient lighting with skyboxes
    4. Configuring lighting in URP
    5. Applying shadows
    6. Understanding shadow calculations
    7. Configuring performant shadows
    8. Optimizing lighting
    9. Understanding static lighting
    10. Baking lightmaps
    11. Applying static lighting to static objects
    12. Summary
  16. Chapter 9: Fullscreen Effects with Postprocessing
    1. Using PostProcessing
    2. Setting up a profile
    3. Using basic effects
    4. Using advanced effects
    5. Advanced effects
    6. Summary
  17. Chapter 10: Sound and Music Integration
    1. Importing audio
    2. Audio types
    3. Configuring the import settings
    4. Integrating and mixing audio
    5. Using 2D and 3D AudioSources
    6. Using an Audio Mixer
    7. Summary
  18. Chapter 11: User Interface Design
    1. Understanding Canvas and RectTransform
    2. Creating a UI with Canvas
    3. Positioning elements with RectTransform
    4. Canvas object types
    5. Integrating assets for the UI
    6. Creating UI controls
    7. Creating a responsive UI
    8. Adapting object positions
    9. Adapting object sizes
    10. Summary
  19. Chapter 12: Creating a UI with the UI Toolkit
    1. Why learn UI Toolkit?
    2. Creating UIs with UI Toolkit
    3. Installing UI Toolkit
    4. Creating UI Documents
    5. Editing UI Documents
    6. Creating UI Stylesheets
    7. Making a Responsive UI with UI Toolkit
    8. Dynamic positioning and sizing
    9. Dynamic Scaling
    10. Using relative positions
    11. Summary
  20. Chapter 13: Creating Animations with Animator, Cinemachine, and Timeline
    1. Using Skinning Animations with Animator
    2. Understanding skinning
    3. Importing skeletal animations
    4. Integration using Animation Controllers
    5. Creating dynamic cameras with Cinemachine
    6. Creating camera behaviors
    7. Creating dolly tracks
    8. Creating cutscenes with Timeline
    9. Creating animation clips
    10. Sequencing our intro cutscene
    11. Summary
  21. Section 3 – Scripting Level Interactivity with C#
  22. Chapter 14: Introduction to C# and Visual Scripting
    1. Creating Scripts
    2. Initial setup
    3. Creating a C# Script
    4. Adding fields
    5. Creating a Visual Script
    6. Using events and instructions
    7. Events and instructions in C#
    8. Events and instructions in Visual Scripting
    9. Using fields in instructions
    10. Common beginner C# script errors
    11. Summary
  23. Chapter 15: Implementing Movement and Spawning
    1. Implementing movement
    2. Moving objects through Transform
    3. Using Input
    4. Understanding Delta Time
    5. Implementing spawning
    6. Spawning Objects
    7. Timing actions
    8. Destroying Objects
    9. Summary
  24. Chapter 16: Physics Collisions and Health System
    1. Configuring Physics
    2. Setting shapes
    3. Physics Object types
    4. Filtering collisions
    5. Detecting collisions
    6. Detecting Trigger events
    7. Modifying the other Object
    8. Moving with Physics
    9. Applying forces
    10. Tweaking Physics
    11. Summary
  25. Chapter 17: Win and Lose Condition
    1. Creating Object Managers
    2. Sharing Variables with the Singleton design pattern
    3. Sharing Variables with Visual Scripting
    4. Creating Managers
    5. Creating Game Modes
    6. Improving our code with events
    7. Summary
  26. Chapter 18: Scripting the UI, Sounds, and Graphics
    1. Scripting the UI
    2. Showing information in the UI
    3. Programming the Pause menu
    4. Scripting feedback
    5. Scripting visual feedback
    6. Scripting audio feedback
    7. Scripting animations
    8. Summary
  27. Chapter 19: Implementing Game AI for Building Enemies
    1. Gathering information with sensors
    2. Creating Three-Filters sensors with C#
    3. Creating Three-Filters sensors with Visual Scripting
    4. Debugging with Gizmos
    5. Making decisions with FSMs
    6. Creating the FSM in C#
    7. Creating transitions
    8. Creating the FSM in Visual Scripting
    9. Executing FSM actions
    10. Calculating our scene's Pathfinding
    11. Using pathfinding
    12. Adding the final details
    13. Summary
  28. Chapter 20: Scene Performance Optimization
    1. Optimizing graphics
    2. Introduction to graphic engines
    3. Using the Frame Debugger
    4. Using batching
    5. Other optimizations
    6. Optimizing processing
    7. Detecting CPU- and GPU-bound
    8. Using the CPU Usage Profiler
    9. General CPU optimization techniques
    10. Optimizing memory
    11. Memory allocation and the garbage collector
    12. Using the Memory Profiler
    13. Summary
  29. Section 4 – Releasing Your Game
  30. Chapter 21: Building the Project
    1. Building a project
    2. Debugging the Build
    3. Debugging Code
    4. Profiling performance
    5. Summary
  31. Chapter 22: Finishing Touches
    1. Iterating your game
    2. Testing and feedback
    3. Interpreting feedback
    4. Releasing your game
    5. Pre-release
    6. Release
    7. Post-release
    8. Summary
  32. Chapter 23: Augmented Reality in Unity
    1. Using AR Foundation
    2. Creating an AR Foundation project
    3. Using tracking features
    4. Building for mobile devices
    5. Building for Android
    6. Building for iOS
    7. Creating a simple AR game
    8. Spawning the Player and Enemies
    9. Coding the Player and Enemy behavior
    10. Summary
    11. Why subscribe?
  33. Other Books You May Enjoy
    1. Packt is searching for authors like you