Share E-Book

Mastering Unreal Engine 5 Game Development with C++ Scripting (Marco Secchi, Marcos Romero)(Z-Library)

Author

,

Rating No ratings yet

Log in to rate

C++
Language English

Mastering Unreal Engine 5 Game Development with C++ Scripting: Build efficient, scalable gameplay systems using advanced C++ in UE5 Explore advanced Unreal Engine 5 C++ techniques to build scalable, high-performance gameplay systems and strengthen your game programming skills.

Format PDF
Size 31.4 MB
4
Views
(First 20 pages)

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Page 1
M astering Unreal Engine 5 G am e D evelopm ent w ith C++ Scripting M arco Secchi First Edition Mastering Unreal Engine 5 Game Development with C++ Scripting Build eff icient, scalable gameplay systems using advanced C++ in UE5 Foreword by Marcos Romero Author of the off icial Unreal Engine 4 Blueprints Instructor's Guide • Write clean, optimized C++ code for Unreal Engine 5 • Work with Unreal Engine architecture for scalable systems • Use pointers eff iciently to improve runtime performance • Apply event-driven programming with C++ and Blueprints • Use Unreal Engine macros to extend gameplay systems • Build Blueprint-accessible, optimized C++ components • Implement data-driven gameplay systems in real projects WHAT YOU WILL LEARN Modern game development demands performance, scalability, and control that visual scripting alone cannot provide. Unreal Engine 5's C++ system off ers this power—but mastering it requires a deeper understanding of engine architecture and gameplay design. In this book, you'll learn how to use C++ to build eff icient gameplay systems, optimize performance, and structure scalable game architectures. You'll explore core engine systems, implement complex logic, and use profi ling and debugging techniques to refi ne and improve your code. Guided by real-world examples and a practical project, you'll apply these concepts in realistic development scenarios, gaining the confi dence to manage complexity and make informed technical decisions. By the end of this book, you'll be able to design, develop, and optimize advanced gameplay systems in Unreal Engine 5 using C++. Mastering Unreal Engine 5 Game Development with C++ Scripting www.packtpub.com Get a free PDF copy of this book packtpub.com/unlock/9781806665938 Marco Secchi
Page 2
Mastering Unreal Engine 5 Game Development with C++ Scripting Build efficient, scalable gameplay systems using advanced C++ in UE5 Marco Secchi
Page 3
Mastering Unreal Engine 5 Game Development with C++ Scripting Copyright © 2026 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. Portfolio Director: Rohit Rajkumar Relationship Lead: Nivedita Pandey Project Manager: Sandip Tadge Content Engineer: Rohan Datta Technical Editor: Tejas Vijay Mhasvekar Indexer: Pratik Shirodkar Production Designer: Shantanu Zagade Growth Lead: Namita Velgekar Production reference: 1120626 Published by Packt Publishing Ltd. Grosvenor House 11 St Paul's Square Birmingham B3 1RB, UK. ISBN 978-1-80666-593-8 www.packtpub.com
Page 4
To my lovely wife Ambra, for those crazy laughs we share when I need them most. – Marco Secchi
Page 5
Foreword Some time ago, I came across a GitHub page that referenced my blog, Romero Blueprints, as a useful resource for Unreal Engine. That page belonged to lecturer Marco Secchi. Since then, I have followed his work, and it quickly became clear how dedicated he is to teaching game development to his students, and how much genuine passion he brings to it. Marco chose to share his extensive knowledge of Unreal Engine with a broader audience through books. In 2023, he authored Multiplayer Game Development with Unreal Engine 5. In 2024, he followed it with Artificial Intelligence in Unreal Engine 5. Now, completing this trilogy, we have Mastering Unreal Engine 5 Game Development with C+ + Scripting. This book is intended for C++ programmers who want to go beyond the fundamentals of Unreal Engine and stand out as professionals. Marco dives deep into the engine's architecture and explores advanced concepts that are essential for building complex projects. This is valuable knowledge for developing scalable, high-performance systems. Throughout the book, the author uses the development of a game as a practical foundation, allowing readers to see how these concepts are applied in real scenarios and to use the project as a true experimentation lab. It is rewarding to see that Marco has been able to create this guide for us: a carefully structured path that would be difficult and time-consuming to follow independently. Marcos Romero Author of the official Unreal Engine 4 Blueprints Instructor's Guide and Blueprints Visual Scripting for Unreal Engine 5
Page 6
Contributors About the author Marco Secchi is a freelance game programmer with over 20 years of experience, working with game studios to develop custom tools and robust gameplay frameworks. He teaches at NABA (Nuova Accademia di Belle Arti) and Politecnico di Bari, where he mentors students and supports their transition into the game development industry. He is also the author of Multiplayer Game Development with Unreal Engine 5 and Artificial Intelligence in Unreal Engine 5, published by Packt.
Page 7
About the reviewers Punya Aachman is a gameplay programmer with over six years of experience in the gaming industry. His work spans game titles, digital twin simulations, and immersive experiences across platforms including PC, PlayStation, Sony's Spatial Reality Display, and various VR headsets. With expertise in gameplay mechanics and building interactive worlds using tools such as Unreal Engine and Blender, along with programming in C++ and Python, Aachman enjoys researching game technology, pushing the boundaries of virtual worlds and exploring new ways to build engaging games. Wanderson Lopes is a Brazilian software engineer and game developer specializing in Unreal Engine, C++, and gameplay and systems engineering. He has contributed to several game titles, both shipped and in development, working across gameplay features, AI, tools, technical systems, and production debugging. Based in the scenic mountain region of Rio de Janeiro, Brazil, Wanderson collaborates with international teams and is passionate about building reliable game systems, improving development workflows, and connecting technical design with practical implementation. As a technical reviewer, he focuses on clarity, accuracy, and real-world applicability for developers.
Page 8
Table of Contents Preface xvii Free benefits with your book ............................................................................ xxiv Part 1: Delving Deep into the Unreal Engine Architecture 1 Chapter 1: Analyzing the Unreal Engine Build Pipeline 3 Technical requirements ........................................................................................ 4 Prerequisite knowledge • 4 Hardware requirements • 5 Software requirements • 6 Understanding the Unreal Engine build pipeline ................................................... 6 Presenting Unreal Build Tool ................................................................................ 7 Exploring UBT core operations • 7 Understanding the main UBT configuration files • 8 Introducing target files • 8 Introducing build files • 9 Using Clang • 10 Common UBT pitfalls • 11 Presenting Unreal Header Tool ............................................................................ 11 Checking the .generated.h file • 12 Extending UHT • 13 Common UHT pitfalls • 13 Presenting Unreal Automation Tool ..................................................................... 14 Understanding the Build Graph • 15 Testing your game • 16 Common UAT pitfalls • 17 Summary ........................................................................................................... 18
Page 9
Credits ............................................................................................................... 18 Chapter 2: Understanding the Engine Reflection System 21 Technical requirements ....................................................................................... 21 Introducing the UE Reflection System ................................................................. 22 Getting to know Reflection advantages • 22 Unveiling the power of Reflection in Unreal Engine • 22 Explaining the header file format ........................................................................ 23 Analyzing a class header • 24 Analyzing a struct header • 25 Analyzing an enum header • 26 Working with interfaces ..................................................................................... 26 Presenting this book's companion project ........................................................... 29 Introducing Paws in the Shell • 29 Project organization • 31 Hands-on with interfaces • 33 Exploring PITS_SafeZoneEligibleInterface • 33 Exploring PITS_HealthInterface • 35 Exploring PITS_StatsWidgetInterface • 36 Develop and self-evaluate • 39 Summary ........................................................................................................... 40 Chapter 3: Mastering Macros 41 Technical requirements ....................................................................................... 41 Understanding core reflection macros ................................................................. 42 Understanding the module export macro • 42 Understanding the UCLASS() macro • 43 Understanding the UFUNCTION() macro • 43 Understanding the UPROPERTY() macro • 44 Using specifiers .................................................................................................. 45 Presenting UCLASS() specifiers • 45 Presenting UFUNCTION() specifiers • 46 Table of Contents viii
Page 10
Presenting UPROPERTY() specifiers • 46 Refining your macros with the metadata specifier ............................................... 47 Presenting a practical example ........................................................................... 48 Hands-on with trigger classes • 49 Exploring the PITS_BaseTrigger class • 50 Exploring the PITS_ExitZone class • 52 Exploring the BP_BasePickup Blueprint • 54 Develop and self-evaluate • 55 Summary ........................................................................................................... 57 Chapter 4: Getting the Best out of Pointers 59 Technical requirements ...................................................................................... 59 Introducing pointers in Unreal Engine ................................................................ 60 Presenting TObjectPtr<T> • 60 Presenting TWeakObjectPtr<T> • 61 Presenting TStrongObjectPtr<T> • 62 Presenting TSoftObjectPtr<T> • 63 Explaining the Unreal Engine smart pointer library ............................................. 65 Presenting TSharedPtr<T> • 65 Presenting TWeakPtr<T> • 65 Presenting TUniquePtr<T> • 66 Presenting TSharedRef<T> • 66 Working with raw pointers (when necessary) ..................................................... 67 Dealing with UObjects • 67 Dealing with non-UObjects • 68 Needing maximum performance • 68 Presenting a practical example ........................................................................... 68 Pooling objects • 69 Analyzing the object pooling implementation • 69 Inspecting PITS_FixedActorPool • 70 Inspecting PITS_PooledObjectInterface • 73 Inspecting PITS_ObjectPoolSubsystem • 74 ix Table of Contents
Page 11
Inspecting PITS_BaseProjectile • 76 Inspecting PITS_WeaponSpawnPointComponent • 78 Testing the implementation in-game • 79 Develop and self-evaluate • 82 Implementing non-fixed object pools • 82 Analyzing and hunting for bugs • 84 Summary ........................................................................................................... 85 Part 2: Enhancing your Coding Skills 87 Chapter 5: Handling Event-Driven Architectures 89 Technical requirements ...................................................................................... 89 Introducing event-driven architectures in Unreal Engine .................................... 90 Working with delegates ....................................................................................... 91 Analyzing non-dynamic single-cast delegates • 92 Declaring a non-dynamic single-cast delegate • 92 Binding to non-dynamic single-cast delegates • 93 Executing a non-dynamic single-cast delegate • 94 Analyzing dynamic single-cast delegates • 95 Declaring a dynamic single-cast delegate • 95 Binding to dynamic single-cast delegates • 95 Executing a non-dynamic single-cast delegate • 95 Analyzing non-dynamic multicast delegates • 96 Declaring a non-dynamic multicast delegate • 96 Binding to non-dynamic multicast delegates • 96 Executing a non-dynamic multicast delegate • 96 Understanding event dispatchers in Blueprints ................................................... 97 Analyzing dynamic multicast delegates • 97 Declaring a dynamic multicast delegate • 97 Binding to dynamic multicast delegates • 97 Executing a dynamic multicast delegate • 98 Using multicast dynamic in Blueprints • 98 Table of Contents x
Page 12
Presenting a practical example ........................................................................... 99 Exploring the PITS_HealthComponent • 100 Analyzing health in PITS_BaseCharacter • 102 Listening for health status changes • 102 Broadcasting health updates • 103 Develop and self-evaluate. • 103 Implementing character death • 104 Summary ......................................................................................................... 104 Chapter 6: Working with Data Structures 107 Technical requirements ..................................................................................... 107 Explaining structures in Unreal Engine .............................................................. 107 Comparing UStruct and UObject • 108 Implementing Data Tables ................................................................................ 109 Defining Data Tables • 110 Accessing Data Tables • 112 Best practices for using FTableRowBase • 113 Implementing Data Asset .................................................................................. 114 Primary vs Secondary Data Asset • 115 Best practices in using Data Assets • 115 Presenting a practical example .......................................................................... 116 Analyzing character stats • 117 Inspecting the FPITS_CharacterDataTableRow structure • 117 Inspecting the APITS_BaseCharacter class • 119 Checking Data Table assets • 120 Analyzing Mission Data • 121 Inspecting the UPITS_MissionDataAsset class • 121 Inspecting the APITS_GameModeBase class • 122 Inspecting the Data Assets inside the project • 123 Develop and self-evaluate • 125 Implementing a Power Data Table • 125 Summary .......................................................................................................... 126 xi Table of Contents
Page 13
Chapter 7: Improving Your Code with Subsystems 129 Technical requirements ..................................................................................... 129 Introducing Subsystems .................................................................................... 129 Presenting Subsystem types • 131 Analyzing Engine Subsystems • 131 Analyzing Editor Subsystems • 131 Analyzing GameInstance Subsystems • 132 Analyzing LocalPlayer Subsystems • 132 Analyzing World Subsystems • 133 Pros and cons of using Subsystems • 133 Explaining a Subsystem lifecycle ........................................................................ 134 Presenting a practical example .......................................................................... 135 Inspecting the UPITS_MissionSubsystem class • 135 Inspecting the UPITS_MissionSubsystem header • 136 Inspecting the UPITS_MissionSubsystem implementation • 138 Inspecting the APITS_GameModeBase class • 139 Inspecting the UPITS_MissionHolderComponent class • 139 Implementing mission pickup • 140 Listening to mission events • 144 Inspecting the UW_MissionContainer • 144 Inspecting the UW_MissionRenderer • 145 Develop and Self-Evaluate • 146 Creating a secondary mission subsystem • 146 Improving enemy characters • 146 Summary .......................................................................................................... 147 Chapter 8: Understanding Multithreading and Concurrency 149 Technical requirements ..................................................................................... 149 Introducing threads and concurrency ................................................................ 150 Presenting the Game Thread • 150 Presenting the Render Thread • 151 Table of Contents xii
Page 14
Presenting the RHI Thread • 151 Introducing Task Graph and Task System ........................................................... 151 Presenting in-engine features ............................................................................ 153 Presenting multithreading techniques • 153 Explaining FRunnable • 153 Task Graph and Task System Abstractions • 154 Explaining TFuture and TPromise • 154 Explaining Async • 155 Explaining ParallelFor • 156 Explaining AsyncTask • 157 Explaining TGraphTask • 159 Explaining FFunctionGraphTask • 160 Explaining FNonAbandonableTask • 160 Presenting a practical example .......................................................................... 162 Implementing an Asynchronous Spawner • 163 Inspecting the asynchronous spawner in a level • 165 Develop and Self-Evaluate • 167 Improving the async spawner • 168 Fixing a parallel spawner • 168 Summary .......................................................................................................... 170 Part 3: Extending and Testing your Game 171 Chapter 9: Working with the Log System 173 Technical requirements ..................................................................................... 173 Introducing the Unreal Engine log system .......................................................... 173 Understanding logging • 174 Presenting log macros • 176 Displaying on-screen messages • 177 Working with UE_LOG ...................................................................................... 178 Using the Visual Logger .................................................................................... 180 Logging with the UE_VLOG macro • 181 xiii Table of Contents
Page 15
Taking advantage of shape drawing macros • 181 Presenting a practical example .......................................................................... 183 Declaring a custom category • 184 Using UE_VLOG • 185 Develop and self-evaluate • 188 Summary ......................................................................................................... 189 Chapter 10: Developing Plugins and Modules 191 Technical requirements ..................................................................................... 191 Introducing module development ...................................................................... 191 Designing and implementing plugins ................................................................. 194 Choosing between a plugin and a module • 196 Implementing plugin API exposure • 196 Presenting a practical example .......................................................................... 197 Presenting the Maze Generator plugin • 198 Inspecting the plugin implementation • 200 Using the plugin • 203 Develop and self-evaluate • 207 Summary ......................................................................................................... 208 Chapter 11: Testing Your Application 209 Technical requirements .................................................................................... 209 Introducing Unreal Engine testing features ....................................................... 210 Working with Functional Tests .......................................................................... 213 Working with Code Quality Tests ....................................................................... 217 Presenting a practical example .......................................................................... 219 Inspecting Functional Tests • 219 Inspecting CQ Tests • 223 Running the tests • 225 Develop and self-evaluate • 226 Continuing the project • 227 Summary .......................................................................................................... 227 Table of Contents xiv
Page 16
Epilogue ........................................................................................................... 228 Chapter 12: Unlock Your Exclusive Benefits 229 Unlock this Book's Free Benefits in 3 Easy Steps ................................................. 230 Other Books You May Enjoy 234 Index 237 xv Table of Contents
Page 17
(This page has no text content)
Page 18
Preface Over the past decades, game development has evolved dramatically, with Unreal Engine standing at the forefront as one of the most powerful and versatile platforms available to creators. In the last few years, the engine has introduced groundbreaking technologies and tools that redefine the boundaries of what is possible in interactive entertainment, simulation, and real-time visualization. Central to harnessing the full potential of this engine is a deep understanding of C++, the programming language that underpins the engine's architecture and performance capabilities. This book has been designed to serve as a guide for game developers who aspire to improve their skills and understand the true power of Unreal Engine through expert-level C++ programming. If you are an intermediate programmer seeking to deepen your knowledge, this volume offers a structured and detailed approach to mastering the intricacies of C++ within this dynamic environment. Unreal Engine 5 is not merely a software, but a complex ecosystem that demands a grasp of both programming fundamentals and engine-specific paradigms. The engine's architecture, with its extensive use of object-oriented programming, memory management, and real-time systems, requires developers to think critically and write efficient, maintainable code. This book addresses these challenges by blending theoretical concepts with practical examples, ensuring readers not only learn the syntax and semantics of C++ but also understand how to apply them effectively within the engine framework. Throughout the chapters, you will encounter a carefully curated progression of topics, starting from the essentials of the engine build pipeline and moving toward advanced subjects such as pointers, delegates, and multithreading. Emphasis is placed on best practices through practical examples, which are crucial for creating high-quality, scalable projects. The journey to mastering C++ in Unreal Engine 5 will be both demanding and rewarding. It will require a lot of patience, and the willingness to explore complex concepts. This book aims to be a trusted companion on that journey, providing clarity, insight, and practical knowledge to empower you, as a developer, to create immersive experiences that push the boundaries of technology and creativity. Welcome to the world of Unreal Engine 5 and the mastery of C++ programming. Your adventure begins here.
Page 19
Who this book is for This book has been written for game developers who possess a solid foundation in Unreal Engine and seek to improve their C++ programming skills to an advanced level. If you are proficient with the engine but wish to deepen your understanding of its C++ framework, this book will serve as an essential resource. Additionally, technical designers and gameplay programmers with experience in Unreal Engine who aim to master advanced principles and techniques for developing more robust and maintainable code will find significant value within its contents. Ideal readers should have a genuine passion for programming and game development, which will enable them to take advantage of the practical examples and comprehensive explanations provided. Whether you are an aspiring developer looking to enhance your skills or an intermediate programmer looking to refine your expertise, this book offers the insights and tools necessary to advance your career and create immersive, high- quality gaming experiences. What this book covers Chapter 1, Analyzing the Unreal Engine Build Pipeline, serves as an introductory overview of the core engine tools, providing readers with the fundamental concepts necessary to effectively work with the engine. Chapter 2, Understanding the Engine Reflection System, offers a detailed explanation of the robust mechanism for exposing C++ classes, functions, and properties to the engine and its associated tools, including Blueprints, serialization, and the editor. Chapter 3, Mastering Macros, explores the purpose, syntax, and best practices for using macros to leverage the full range of features available within the engine system. Chapter 4, Getting the Best out of Pointers, guides readers through the complexities of safely managing pointers within the Unreal Engine environment. Chapter 5, Handling Event-Driven Architectures, introduces the principles of event-driven design in Unreal Engine, showing how delegates and event dispatchers facilitate modular and responsive game systems. Chapter 6, Working with Data Structures, explains the unique aspects of managing data structures in Unreal Engine, highlighting the advantages of using structs and how to expose their properties to the Unreal Editor. Chapter 7, Improving Your Code with Subsystems, delves into the use of Subsystems to organize game logic and functionality in a modular and efficient manner. Preface xviii
Page 20
Chapter 8, Understanding Multithreading and Concurrency, presents advanced techniques in multithreading aimed at enhancing game performance and efficiency when required. Chapter 9, Working with the Log System, outlines common logging methods within the engine and provides guidance on maximizing their effectiveness. Chapter 10, Developing Plugins and Modules, covers the essential steps for creating scalable features through the engine's module and plugin systems. Chapter 11, Testing Your Application, introduces readers to the capabilities of the Unreal Engine testing framework, demonstrating how to use its features to maintain clean and reliable code. To Get the Most Out of This Book To maximize the benefits of this book, it is important to approach it with a solid foundation in Unreal Engine and a genuine enthusiasm for game programming. This book is aimed at developers who already have proficiency with Unreal Engine and are eager to elevate their C++ programming skills to an advanced level. Additionally, to get the most out of the material, it is highly recommended to actively engage with the practical code examples and exercises, experimenting by modifying and extending them to fit your own projects. Focus on understanding not just the "how," but the "why" behind Unreal Engine's architecture and techniques presented in every chapter. This book assumes familiarity with core concepts, so be prepared to challenge yourself with complex topics such as memory management, performance optimization, and scalable code design. Additionally, integrating the lessons learned here into your daily development workflow will reinforce your skills and help you write cleaner, more maintainable code. Use this book as a reference to solve real-world problems and as a guide to architecting gameplay systems. By combining theory with hands-on practice, you will transform your existing knowledge into expert-level proficiency, and you will be subsequently able to work on high-quality projects that stand out in the game development industry. Download the example code files This book includes a complete downloadable code bundle containing all the example projects and files used throughout the chapters. We recommend downloading the bundle so you can follow along smoothly and experiment with the examples. Use the bundle as a practical starting point. Modify it, extend it, and apply what you learn by creating your own variations as you progress through the chapters. xix Preface
The above is a preview of the first 20 pages. Register to read the complete e-book.

Recommended for You

Loading recommended books...
Failed to load, please try again later

Tip the Site

Scan the WeChat Pay or Alipay code to tip. No login required.

WeChat Pay
Alipay
← Back to List