Unity 2020 By Example - Third Edition

Book description

Learn Unity game development with C# through a series of practical projects ranging from building a simple 2D game to adding AR/VR experiences and machine learning capabilities in a simple yet effective way

Key Features

  • Gain a high-level overview of the Unity game engine while building your own games portfolio
  • Discover best practices for implementing game animation, game physics, shaders, and effects
  • Create fully featured apps, including Space shooter and a 2D adventure game, and develop AR/VR experiences and Game AI agents

Book Description

The Unity game engine, used by millions of developers around the world, is popular thanks to its features that enable you to create games and 3D apps for desktop and mobile platforms in no time. With Unity 2020, this state-of-the-art game engine introduces enhancements in Unity tooling, editor, and workflow, among many other additions.

The third edition of this Unity book is updated to the new features in Unity 2020 and modern game development practices. Once you've quickly got to grips with the fundamentals of Unity game development, you'll create a collection, a twin-stick shooter, and a 2D adventure game. You'll then explore advanced topics such as machine learning, virtual reality, and augmented reality by building complete projects using the latest game tool kit. As you implement concepts in practice, this book will ensure that you come away with a clear understanding of Unity game development.

By the end of the book, you'll have a firm foundation in Unity development using C#, which can be applied to other engines and programming languages. You'll also be able to create several real-world projects to add to your professional game development portfolio.

What you will learn

  • Learn the fundamentals of game development, including GameObjects, components, and scenes
  • Develop a variety of games in C# and explore the brand new sprite shaping tool for Unity 3D and 2D games
  • Handle player controls and input functionality for your Unity games
  • Implement AI techniques such as pathfinding, finite state machines, and machine learning using Unity ML-Agents
  • Create virtual and augmented reality games using UnityVR and AR Foundation
  • Explore the cutting-edge features of Unity 2020 and how they can be used to improve your games

Who this book is for

If you are a game developer or programmer new to Unity and want to get up and running with the game engine in a hands-on way, this book is for you. Unity developers looking to work on practical projects to explore new features in Unity 2020 will find this book useful. A basic understanding of C# programming is required.

Table of contents

  1. Unity 2020 By Example Third Edition
  2. Why subscribe?
  3. Contributors
  4. About the author
  5. About the reviewers
  6. Packt is searching for authors like you
  7. 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. Reviews
  8. Chapter 1: Exploring the Fundamentals of Unity
    1. Technical requirements
    2. Exploring new features in Unity 2020
    3. Introducing the first game
      1. Introducing the Project panel
      2. Importing assets
    4. Starting a level
      1. Creating a scene
      2. Adding a floor mesh
      3. Transforming objects
      4. Adding lighting and a skybox
    5. Testing the game
      1. Adding a playable character
      2. Using the game panel
      3. Understanding console messages
    6. Improving the scene
      1. Adding a water plane
      2. Adding a coin
    7. Saving the scene
    8. Summary
    9. Test your knowledge
    10. Further reading
  9. Chapter 2: Creating a Collection Game
    1. Technical requirements
    2. Working with Materials
      1. Creating a coin Material
      2. Editing the Material
      3. Assigning the Material
    3. Scripting in Unity
      1. Creating a script
      2. Running the script
    4. Recording the total coin count
      1. Collecting coins
      2. Introducing colliders
      3. Counting coins
      4. Working with Tags
    5. Working with prefabs
    6. Creating a timer
      1. Adding fireworks
      2. Lighting the fireworks
    7. Playtesting
    8. Building the game
    9. Summary
    10. Test your knowledge
    11. Further reading
  10. Chapter 3: Creating a Space Shooter
    1. Technical requirements
    2. Looking ahead – the completed project
    3. Starting the project
    4. Importing assets
      1. Importing textures
      2. Importing audio
    5. Creating the player object
      1. Creating the GameObject
      2. Adding components
      3. Controlling the player
      4. Limiting movement
    6. Configuring the cameras
    7. Creating a Health component
    8. Creating the explosive particle system
      1. Selecting the particle system
      2. Customizing the particle system
    9. Creating the enemy object
      1. Moving the enemy
      2. Turning the enemy
      3. Dealing damage to the player
    10. Spawning enemies
    11. Summary
    12. Test your knowledge
    13. Further reading
  11. Chapter 4: Continuing the Space Shooter Game
    1. Technical requirements
    2. Creating the projectile system
      1. Implementing the projectile spawn location
      2. Creating the projectile prefab
      3. Creating an object pool
      4. Spawning projectiles
      5. Configuring projectile physics
    3. Customizing controls
    4. Creating the score system
      1. Implementing the score UI
      2. Scripting the score logic
    5. Adding the final touches
      1. Adding a background image
      2. Implementing background music
    6. Summary
    7. Test your knowledge
    8. Further reading
  12. Chapter 5: Creating a 2D Adventure Game
    1. Technical requirements
    2. Getting started
    3. Configuring the game view
      1. Changing the Game panel's resolution
      2. Adjusting the scene camera's size
    4. Creating an environment
    5. Adding post-processing effects
    6. Implementing environmental physics
    7. Creating a 2D player
      1. Using the Sprite Editor
      2. Creating the player GameObject
      3. Adjusting the sorting order
      4. Adding the player to the physics engine
    8. Moving the player
      1. Writing the movement script
      2. Implementing the movement script
    9. Optimizing using sprite packing
    10. Summary
    11. Test your knowledge
    12. Further reading
  13. Chapter 6: Continuing the 2D Adventure
    1. Technical requirements
    2. Constructing additional scenes
      1. Introducing levels two and three
      2. Creating platforms using sprite shaping
    3. Implementing moving platforms
      1. Creating the platform object
      2. Scripting platform movement
    4. Implementing player kill zones
    5. Creating the UI health bar
      1. Preparing the scene for the UI
      2. Scripting the health bar
    6. Summary
    7. Test your knowledge
    8. Further reading
  14. Chapter 7: Completing the 2D Adventure
    1. Technical requirements
    2. Adding gun turrets
      1. Creating projectiles
      2. Scripting projectile movement
      3. Completing the turret
    3. Creating an NPC
    4. Implementing a quest system
      1. Managing the quests
      2. Assigning quests to the player
      3. Creating the quest item
    5. Summary
    6. Test your knowledge
    7. Further reading
  15. Chapter 8: Creating Artificial Intelligence
    1. Technical requirements
    2. Looking ahead – an overview of the project
    3. Importing assets
    4. Constructing the terrain
    5. Generating the navigation mesh
    6. Implementing the NPC
    7. Testing navigation 
    8. Animating the NPC
      1. Creating animation states
      2. Using Blend Trees
    9. Patrolling the environment
    10. Entering the world
    11. Summary
    12. Test your knowledge
    13. Further reading
  16. Chapter 9: Continuing with Intelligent Enemies
    1. Technical requirements
    2. Providing the enemy with sight
    3. Implementing the FSM
    4. Patrolling the environment
    5. Chasing the player
    6. Attacking the player
      1. Implementing the state
      2. Animating the state
    7. Summary
    8. Test your knowledge
    9. Further reading
  17. Chapter 10: Evolving AI Using ML-Agents
    1. Technical requirements
    2. Introducing ML-Agents
    3. Setting the scene
    4. Importing assets
    5. Installing ML-Agents
    6. Creating the environment
    7. Spawning objects
      1. Creating the prefabs
      2. Writing the spawn functionality
    8. Creating the Agent
      1. Configuring the Agent's behavior
      2. Defining the network's input
      3. Writing the Agent script
    9. Training the Agent
    10. Embedding the model
    11. Summary
    12. Test your knowledge
    13. Further reading
  18. Chapter 11: Entering Virtual Reality
    1. Technical requirements
    2. Preparing the project
    3. Creating scene lighting
      1. Removing existing lighting
      2. Adding base lighting
      3. Creating emissive wall panels
      4. Adding Light Probes
      5. Importing the post-processing stack
      6. Creating a post-processing volume
      7. Configuring the camera
      8. Enabling post-processing effects
    4. Preparing for VR
    5. Test your knowledge
    6. Further reading
  19. Chapter 12: Completing the VR Game
    1. Technical requirements
    2. Spawning objects
      1. Creating an Object Pool
      2. Instantiating objects using the Object Pool
    3. Creating the enemy
      1. Creating the enemy Prefab
      2. Implementing navigation
      3. Adding behavior states
    4. Implementing a damage system
      1. Adding enemy health
      2. Attacking using particles
      3. Damaging the enemy
    5. Summary
    6. Test your knowledge
    7. Further reading
  20. Chapter 13: Creating an Augmented Reality Game Using AR Foundation
    1. Technical requirements
    2. Introducing the project
    3. Getting started with AR
      1. Creating a URP project
      2. Installing AR libraries
      3. Configuring player settings
      4. Importing the required packages
    4. Creating an AR scene
    5. Placing an object in the world
    6. Testing on devices
      1. Testing on Android
      2. Testing on iOS
    7. Implementing AR in the URP
    8. Summary
    9. Test your knowledge
    10. Further reading
  21. Chapter 14: Completing the AR Game with the Universal Render Pipeline
    1. Technical requirements
    2. Detecting planes
      1. Adding a Plane Manager
      2. Retrieving plane data
    3. Adding a placement marker
      1. Designing the marker
      2. Placing the marker
    4. Placing objects in the world
    5. Post-processing in the URP
    6. Summary
    7. Test your knowledge
    8. Further reading
  22. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Unity 2020 By Example - Third Edition
  • Author(s): Robert Wells
  • Release date: September 2020
  • Publisher(s): Packt Publishing
  • ISBN: 9781800203389