Game Development Patterns with Unreal Engine 5

Book description

Improve your game's code with design patterns to make it more readable, reusable, modular, and optimized, guided by an Unreal Authorized Instructor to enhance your overall use of C++ with Unreal Engine

Key Features

  • Explore programming patterns, structures, and principles and their applications in Unreal Engine 5 game development
  • Translate code from Blueprint to C++ to implement performant solutions in game development
  • Build a decoupled communications hierarchy and become a better game developer
  • Purchase of the print or Kindle book includes a free PDF eBook

Book Description

Design patterns serve as a toolkit of techniques and practices that enable you to write code that’s not only faster, but also more manageable. With this book, you’ll explore a range of design patterns and learn how to apply them to projects developed in Unreal Engine 5.

You’ll begin by delving into the foundational principles of coding and develop a solid understanding of the concepts, challenges, and benefits of using patterns in your code. As you progress, you’ll identify patterns that are woven into the core of Unreal Engine 5 such as Double Buffer, Flyweight, and Spatial Partitioning, followed by some of the existing tool sets that embody patterns in their design and usage including Component, Behavior Tree, and Update.

In the next section of the book, you’ll start developing a series of gameplay use cases in C++ to implement a variety of design patterns such as Interface and Event-based Observers to build a decoupled communications hierarchy. You’ll also work with Singleton, Command, and State, along with Behavioral Patterns, Template, Subclass Sandbox, and Type Object. The final section focuses on using design patterns for optimization, covering Dirty Flag, Data Locality, and Object Pooling.

By the end, you’ll be proficient in designing systems with the perfect C++/Blueprint blend for maintainable and scalable systems.

What you will learn

  • Grasp the essence of design patterns and their inherent utility
  • Understand the layers within UE 5 and how they work together
  • Identify the relationship between C++ code and Blueprint in Unreal Engine 5
  • Recognize the design patterns found within existing Unreal Engine 5 functions
  • Explore design patterns to understand their purpose and application within Unreal Engine 5
  • Creatively apply design patterns to existing code to overcome common challenges

Who this book is for

If you are a beginner or intermediate game developer working with Unreal Engine and looking to improve your C++ coding practices, this book is tailor-made to help you produce clean, reusable code through the application of design patterns. While this book will cover introductory tasks to show the fundamentals of Unreal Engine 5, its primary purpose is not to teach Unreal Engine from scratch. Prior experience with Unreal Engine will be beneficial, but don’t fret if your knowledge isn’t in-depth; the book will introduce tools and features as needed.

Table of contents

  1. Game Development Patterns with Unreal Engine 5
  2. Foreword
  3. Contributors
  4. About the authors
  5. About the reviewer
  6. 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. Conventions used
    6. Get in touch
    7. Share Your Thoughts
    8. Once you’ve read Game Development Patterns with Unreal Engine 5, we’d love to hear your thoughts! Please click here to go straight to the Amazon review page for this book and share your feedback.
    9. Download a free PDF copy of this book
  7. Part 1:Learning from Unreal Engine 5
  8. Chapter 1: Understanding Unreal Engine 5 and its Layers
    1. Technical requirements
    2. Introducing Unreal Engine 5
    3. Installing Unreal Engine 5 and preparing your development environment
    4. The “Fuzzy” layer – bridging the gap from C++ to Blueprint
      1. Property Specifiers
      2. Function Specifiers
      3. Useful inheritance
    5. Translating back from Blueprint to C++
      1. Worked example
    6. Summary
    7. Questions
      1. Answers
  9. Chapter 2: “Hello Patterns”
    1. Technical requirements
    2. S.O.L.I.D. principles
      1. Single responsibility
      2. Open-closed
      3. Liskov substitution
      4. Interface segregation
      5. Dependency inversion
    3. Exploring solutions to common problems
      1. The moving box problem
      2. The rotating box problem
      3. The cascading cast chain problem
    4. The trade-off
    5. Summary
  10. Chapter 3: UE5 Patterns in Action – Double Buffer, Flyweight, and Spatial Partitioning
    1. Technical requirements
    2. Double buffer
    3. Flyweight
    4. Spatial partitioning
      1. Introducing World Partition
      2. Understanding when objects are loaded
      3. Ensuring actors are loaded when required
      4. Enabling World Partition on an existing level
    5. Summary
  11. Chapter 4: Premade Patterns in UE5 – Component, Update Method, and Behavior Tree
    1. Technical requirements
    2. Understanding and creating components
    3. Applying the update method for prototyping gameplay
    4. Working with behavior trees
      1. Creating the AI controller
      2. Creating the Blackboard asset
      3. Building the behavior tree
    5. Summary
  12. Part 2: Anonymous Modular Design
  13. Chapter 5: Forgetting Tick
    1. Technical requirements
    2. Before we begin
    3. A world that ticks
    4. A clock that stops
    5. Event driven systems
    6. Summary
  14. Chapter 6: Clean Communication – Interface and Event Observer Patterns
    1. Technical requirements
    2. Interfacing communication across classes in UE5
      1. Blueprint interfaces
      2. Interface events versus functions
      3. Interfaces in C++
      4. Building an example interface communication
    3. Implementing event delegate communication across UE5
      1. Event delegates in Blueprint
      2. Event delegates in C++
      3. Building a useful delegate tool
    4. Summary
  15. Chapter 7: A Perfectly Decoupled System
    1. Technical requirements
    2. Using UML to plan a sample hierarchy
      1. What are the types of class relations?
      2. What is a sequence diagram?
    3. Decoupling the reference train
      1. Modularity and decoupling
      2. Establishing infrastructure
      3. Implementing decoupled design in an example
      4. Benefits of decoupling
    4. Summary
  16. Part 3: Building on Top of Unreal
  17. Chapter 8: Building Design Patterns – Singleton, Command, and State
    1. Technical requirements
    2. Implementing a Singleton pattern – understanding why it’s a Pandora’s box
    3. Implementing the Command pattern for different use cases
      1. Command pattern for undo functionality in Blueprint Utilities
      2. Command pattern for gameplay in C++
    4. Creating the many levels of a state machine
      1. Exploring animation state machines
      2. Enum/switch implementation
      3. Static versus instanced states
      4. Concurrent state machines
      5. Hierarchical state machines
      6. Pushdown automata
    5. Summary
  18. Chapter 9: Structuring Code with Behavioral Patterns – Template, Subclass Sandbox, and Type Object
    1. Technical requirements
    2. Exploring the template pattern
      1. Building the template (parent class)
      2. Creating child classes
      3. Template pistol
      4. Template shotgun
    3. Understanding subclass sandbox
      1. Building the sandbox (parent class)
      2. Creating child classes
      3. Sandbox pistol
      4. Sandbox shotgun
    4. Type object pattern
      1. Variants
      2. Data Tables
      3. Data Assets
    5. Summary
  19. Chapter 10: Optimization through Patterns
    1. Technical requirements
    2. Using dirty flags to reduce unnecessary processing
      1. Application of dirty flags
    3. How data locality affects code efficiency
      1. Hot/cold splitting
      2. Contiguous arrays
    4. Object pooling our resources to save time later
      1. Implementing object pooling
      2. Making an object pool
    5. Summary
  20. Index
    1. Why subscribe?
  21. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Download a free PDF copy of this book

Product information

  • Title: Game Development Patterns with Unreal Engine 5
  • Author(s): Stuart Butler, Tom Oliver
  • Release date: January 2024
  • Publisher(s): Packt Publishing
  • ISBN: 9781803243252