Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Game Development Patterns with Unity 2021 - Second Edition
Game Development Patterns with Unity 2021 - Second Edition

Game Development Patterns with Unity 2021: Explore practical game development using software design patterns and best practices in Unity and C#, Second Edition

By David Baron
€14.99 per month
Book Jul 2021 246 pages 2nd Edition
eBook
€22.99 €15.99
Print
€28.99
Subscription
€14.99 Monthly
eBook
€22.99 €15.99
Print
€28.99
Subscription
€14.99 Monthly

What do you get with a Packt Subscription?

Free for first 7 days. $15.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details


Publication date : Jul 30, 2021
Length 246 pages
Edition : 2nd Edition
Language : English
ISBN-13 : 9781800200814
Vendor :
Unity Technologies
Category :
Languages :
Table of content icon View table of contents Preview book icon Preview Book

Game Development Patterns with Unity 2021 - Second Edition

Before We Begin

Welcome to the second edition of Hands-On Game Development Patterns with Unity; this edition is not merely a revision of the previous version, but a complete upgrade of the original book. After the first edition came out, I was fortunate to get a lot of constructive feedback, which inspired me to improve the structure of this new edition. As we will review in the following sections, this book concentrates on the "hands-on" aspect of the title; in other words, we are going to get our hands dirty and work on implementing systems and features for a fully playable prototype of a game with design patterns. This new approach to the book's structure will be more tangible and also more enjoyable. It's more fun to work on a playable game than with random code examples. So, before we begin, in the following sections, I will establish specific parameters to the book's content and overall approach.

Let's quickly review the topics we are going to see in this chapter, as follows:

  • Notes about the new edition
  • The philosophy of the book
  • What are design patterns?
  • Which subjects aren't covered in this book?
  • The game project

Notes about the new edition

As mentioned, I redesigned this edition entirely based on reader feedback from the previous version, and so, in consequence, I decided to cut some content from the last edition that readers considered to be trivial, such as the following:

  • Game loop and update pattern chapters: These chapters focused too much on theory and didn't align themselves with the book's "hands-on" approach.
  • Anti-patterns chapter: Anti-patterns is a complex and deep subject that deserves a book in itself to do it justice.

The end goal of this edition is not to cut content but to instead redesign the book to focus on practical game development uses of software design patterns in order to build a complete project. In other words, unlike the first edition, in which I took the approach of presenting each design pattern in isolation and with a self-contained code example, we will use them unitedly this time.

I added some chapters in this edition that were lacking in the previous version, such as the following:

  • The Game Design Document: The beginning of a new game project often starts with writing a GDD. A GDD is a document that will help us understand the design intention behind the game systems and mechanics that we will build throughout the book.
  • A Short Primer to Programming in Unity: We will use several advanced Unity engine concepts, C# features, and object-oriented programming (OOP) techniques throughout the book. In this chapter, we will take the time to review them to establish a shared knowledge base.

The philosophy of the book

This book is not a technical bible or the ultimate authority on how to use design patterns with Unity, and it's best described as a guide filled with design propositions to resolve some game programming challenges in Unity. The code examples included in each chapter are not flawless implementations because the art of design and programming is a continuous refinement process, and so the core goal of this book is to introduce you to potential solutions and inspire you to find better ones.

I always recommend seeking at least two sources of information on any technical subject, particularly concerning design patterns. It's essential to avoid getting too influenced by a single perspective of a complicated subject matter to the point that it becomes dogma instead of knowledge.

What are design patterns?

For those that are very new to programming, design patterns might be a novel concept. The simplest way of explaining design patterns is that they are reusable solutions to common software development problems. An architect named Christopher Alexander originated the notion of design patterns to describe reusable design ideas. In the late 1980s, inspired by the concept, software engineers started experimenting with applying concepts of reusable design patterns to software development, and over the years several books were written on the subject, such as the classic Design Patterns: Elements of Reusable Object-Oriented Software by the so-called "Gang of Four".

But in this book, I will be avoiding covering the academic side of software design patterns, focusing instead on their practical use for programming game mechanics and systems in Unity. I will present a recurrent game programming problem in each chapter and propose resolving it using a specific design pattern adapted for the Unity application programming interface (API).

Which subjects aren't covered in this book?

There are many facets to game programming, and a single book cannot cover them all with the depth they deserve. This book has a specific focus: design patterns and the Unity engine. So, if you are starting your journey into becoming a professional game programmer, this book will not be enough to complete your education. But luckily, some very talented individuals in our industry have taken the time to write very specialized books on core topics of game development. I recommend that anyone interested in joining the game industry reads each of the following reference books:

  • Physics programming: Real-Time Collision Detection, Christer Ericson
  • Engine programming: Game Engine Architecture, Jason Gregory
  • Three-dimensional (3D) programming: Mathematics for 3D Game Programming and Computer Graphics, Eric Lengyel
  • Artificial intelligence (AI) programming: Programming Game AI By Example, Mat Buckland 

I have focused the content of this book on a specific aspect of game programming, but I will mention concepts from other domains of game development throughout the book. So, if you feel unfamiliar with some of the topics mentioned, take the time to explore them in depth; the time invested in researching will make you a better game programmer.

The game project

Throughout this book, we will be working continuously on a single game project example. The working title of the game is Edge Racer. As the title may indicate, it's a racing game; to be more specific, it's a futuristic racing game in which the player drives high-speed motorcycles. We will review the core concepts of the game in more detail in Chapter 2The Game Design Document. But before continuing, I wish to list the reasons I decided on a racing game instead of another type of game—for example, a role-playing game (RPG)—as follows:

  • Simplicity: Racing games have a simple premise—get to the finish line as fast as possible without crashing. Because this book is not about game design but game programming, I wanted a simple type of game that will permit us to focus on learning about software design patterns and not get bogged down with the implementation details of complex game mechanics.
  • Fun: I've worked on various games of many different genres, and I always found that racing games are the most fun to develop because they are enjoyable to test. In racing games, you can speed-run to specific parts of the game and quickly reproduce bugs or test new features. Unlike other games with deep game mechanics and large maps, such as RPGs, racing games are usually quicker to debug.
  • Performance: The main challenge of programming a racing game is maintaining a consistent frame rate as you add more features and content. So, I find working on racing games forces you to maintain good game-programmer habits by always keeping an eye on how fast your code is running and not just making it more readable.
  • Personal: There's also a personal reason for me choosing a racing game—it's because it's my favorite genre. I love playing racing games and I love making them. 

In conclusion, the game industry produces various products in many genres and sub-genres, but a racing game is a good reference point for us to start learning about design patterns in Unity because it's a simple context and forces us to keep an eye on keeping code clean and fast.

Summary

In this chapter, we reviewed the book's structure so that we can start with a clear understanding of its content and purpose. The key takeaway is that we will be using design patterns to build the mechanics and systems of a new racing game named Edge Racer.

In the next chapter, we will review the GDD to have a solid understanding of the game project that we will be working on in the upcoming chapters. I would not recommend skipping it because it's always a good practice to get to know as much as possible about a game project before starting writing code, as this helps in understanding how the parts fit the whole.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Gain a comprehensive overview of Unity engine architecture and coding model
  • Build a complete racing game using software design patterns and understand how to implement them in Unity
  • Download the source code of the complete prototype demonstrating each of the software patterns used

Description

This book is written for every game developer ready to tackle the bigger picture and start working with advanced programming techniques and design patterns in Unity. Game Development Patterns with Unity 2021 is an introduction to the core principles of reusable software patterns and how to employ them to build components efficiently. In this second edition, you'll tackle design patterns with the help of a practical example; a playable racing game prototype where you’ll get to apply all your newfound knowledge. Notable updates also include a game design document (GDD), a Unity programming primer, and the downloadable source code of a complete prototype. Your journey will start by learning about overall design of the core game mechanics and systems. You’ll discover tried-and-tested software patterns to code essential components of a game in a structured manner, and start using classic design patterns to utilize Unity's unique API features. As you progress, you'll also identify the negative impacts of bad architectural decisions and understand how to overcome them with simple but effective practices. By the end of this Unity book, the way you develop Unity games will change – you’ll adapt a more structured, scalable, and optimized process that will help you take the next step in your career.

What you will learn

Structure professional Unity code using industry-standard development patterns Identify the right patterns for implementing specific game mechanics or features Develop configurable core game mechanics and ingredients that can be modified without writing a single line of code Review practical object-oriented programming (OOP) techniques and learn how they re used in the context of a Unity project Build unique game development systems such as a level editor Explore ways to adapt traditional design patterns for use with the Unity API

What do you get with a Packt Subscription?

Free for first 7 days. $15.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details


Publication date : Jul 30, 2021
Length 246 pages
Edition : 2nd Edition
Language : English
ISBN-13 : 9781800200814
Vendor :
Unity Technologies
Category :
Languages :

Table of Contents

22 Chapters
Preface Chevron down icon Chevron up icon
Sections 1: Fundamentals Chevron down icon Chevron up icon
Before We Begin Chevron down icon Chevron up icon
The Game Design Document Chevron down icon Chevron up icon
A Short Primer to Programming in Unity Chevron down icon Chevron up icon
Section 2: Core Patterns Chevron down icon Chevron up icon
Implementing a Game Manager with the Singleton Chevron down icon Chevron up icon
Managing Character States with the State Pattern Chevron down icon Chevron up icon
Managing Game Events with the Event Bus Chevron down icon Chevron up icon
Implement a Replay System with the Command Pattern Chevron down icon Chevron up icon
Optimizing with the Object Pool Pattern Chevron down icon Chevron up icon
Decoupling Components with the Observer Pattern Chevron down icon Chevron up icon
Implementing Power-Ups with the Visitor Pattern Chevron down icon Chevron up icon
Implementing a Drone with the Strategy Pattern Chevron down icon Chevron up icon
Using the Decorator to Implement a Weapon System Chevron down icon Chevron up icon
Implementing a Level Editor with Spatial Partition Chevron down icon Chevron up icon
Section 3: Alternative Patterns Chevron down icon Chevron up icon
Adapting Systems with an Adapter Chevron down icon Chevron up icon
Concealing Complexity with a Facade Pattern Chevron down icon Chevron up icon
Managing Dependencies with the Service Locator Pattern Chevron down icon Chevron up icon
About Packt Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Filter icon Filter
Top Reviews
Rating distribution
Empty star icon Empty star icon Empty star icon Empty star icon Empty star icon 0
(0 Ratings)
5 star 0%
4 star 0%
3 star 0%
2 star 0%
1 star 0%

Filter reviews by


No reviews found
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.