Table Of ContentBlueprints Visual Scripting for Unreal Engine 5 M T U B
Third Edition arcos Ro hird Edit nreal E lueprin Blueprints Visual
m io n t Scripting for
er n gin s V
Uprnorgeraal mEnmgeinres 'tso B clureeaptrein bta vsiesu ealel mscerinpttsin tgh asty sctaenm b ee neaxbtelensd deeds bigyn deerss itgon secrrsi.p Wt tihthe itrh gisa mboeosk a, nyodu 'll o | B e 5 isua
explore all the features of the Blueprint Editor, along with expert tips, shortcuts, and best practices. re l Unreal Engine 5
n S
d c
The book guides you through using variables, macros, and functions, and helps you learn about e r
n ip
object-oriented programming (OOP). You'll discover the Gameplay Framework and advance to S t
e i
learning how Blueprint Communication allows one Blueprint to access information from another w n Third Edition
e g
Blueprint. Later chapters focus on building a fully functional game step by step. You'll start with ll f
o
a basic fi rst-person shooter (FPS) template, and each chapter will build on the prototype to create r
an increasingly complex and robust game experience. You'll then progress from creating basic
shooting mechanics to more complex systems such as user interface elements and intelligent
Unleash the true power of Blueprints to create
enemy behavior. The book demonstrates how to use arrays, maps, enums, and vector operations
and introduces the elements needed for VR game development. In the fi nal chapters, you’ll learn impressive games and applications in UE5
how to implement procedural generation and create a product confi gurator.
By the end of this book, you'll have learned how to build a fully functional game and have the skills
required to develop an entertaining experience for your audience.
Things you will learn:
• Understand programming concepts • Explore all the features of the Blueprint
in Blueprints editor, such as the Components tab,
• Create prototypes and iterate new game Viewport, and Event Graph
mechanics rapidly • Get to grips with OOP concepts and explore
• Build user interface elements and the Gameplay Framework
interactive menus • Work with virtual reality development in
• Use advanced Blueprint nodes to manage UE Blueprint
the complexity of a game • Implement procedural generation and
create a product confi gurator
Marcos Romero | Brenden Sewell
Blueprints Visual
Scripting for
Unreal Engine 5
Third Edition
Unleash the true power of Blueprints to create
impressive games and applications in UE5
Marcos Romero
Brenden Sewell
BIRMINGHAM—MUMBAI
Blueprints Visual Scripting for Unreal Engine 5
Third Edition
Copyright © 2022 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 authors, 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.
Publishing Product Manager: Rohit Rajkumar
Senior Editor: Aamir Ahmed
Content Development Editor: Feza Shaikh
Technical Editor: Simran Udasi
Copy Editor: Safis Editing
Project Coordinator: Rashika Ba
Proofreader: Safis Editing
Indexer: Rekha Nair
Production Designer: Shyam Sundar Korumilli
Marketing Coordinator: Teny Thomas
First published: July 2015
Second edition: August 2019
Third edition: April 2022
Production reference: 1290422
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-80181-158-3
www.packt.com
Contributors
About the authors
Marcos Romero is the author of the Romero Blueprints blog, which is one of the main
references on the internet to learn about Blueprints. Epic Games invited Marcos to the
Unreal Engine 4 closed beta program to experiment and collaborate with the evolution
of the tools. He was also one of the first recipients of Unreal Dev Grants for Education.
Marcos is a well-known figure in the Unreal community and, for Epic Games, he wrote
the official Blueprints Compendium and Blueprints Instructors' Guide.
I would like to thank Luis Cataldi and Tom Shannon from Epic Games for
sharing and recommending my Blueprint materials to developers around
the world.
I'd also like to thank Elinaldo Azevedo, Filipe Mendes, and Ingrid Mendes,
for their dedication to Beljogos, which is a local game development group
that I founded in the city of Belém, northern Brazil.
Brenden Sewell is a creative director with a decade of experience leading teams in the
development of compelling interactive experiences that entertain, teach, and inspire.
Prior to joining E-Line, he explored the intersection of educational practice and industry
game development, culminating in his work as the principal game designer at the Center
for Games and Impact. There, he specialized in the development of immersive games
for STEM education and teachers' professional development. Since joining the E-Line
team, he has led developments from concept, prototyping, and production, to release on
a variety of projects ranging from a brain-training first-person shooter to a construction
sandbox exploring the future of digital fabrication.
About the reviewer
Agne Skripkaite is an Unreal Engine software engineer. Coming from a strong
background in physics (with a Bachelor's of Science in Physics from the University of
Edinburgh), Agne likes to focus on the why of things and the overarching structure of
code in games. In the past, they have worked on Unreal Engine VR applications – both
room-scale and seated games, becoming an experienced user comfort and motion
sickness mitigation specialist for these contexts. This is the fifth Packt Publishing book on
Unreal Engine that Agne has reviewed as a technical editor.
Table of Contents
Preface
Part 1: Blueprint Fundamentals
1
Exploring the Blueprint Editor
Installing Unreal Engine 4 The Components panel 13
Creating new projects and The My Blueprint panel 14
using templates 4 The Details panel 15
The Viewport panel 15
Blueprints Visual Scripting 8
The Event Graph panel 16
Opening the Level Blueprint Editor 8
Creating a Blueprint Class 10 Adding Components to
a Blueprint 17
The Blueprint Class
Summary 19
Editor interface 11
Quiz 20
The Toolbar panel 12
2
Programming with Blueprints
Storing values in variables 22 Creating expressions
Defining the behavior of with operators 29
a Blueprint with events Arithmetic operators 29
and actions 25 Relational operators 30
Events 26 Logical operators 31
Actions 27
Organizing the script with
The execution path 28
macros and functions 32
Creating macros 32
vi Table of Contents
Creating functions 36 Summary 41
Step-by-step example 39 Quiz 41
Macros versus functions versus events 41
3
Object-Oriented Programming and the Gameplay Framework
Getting familiar with OOP 44 Exploring the other Gameplay
Framework classes 58
Classes 44
Instances 44 Pawn 60
Inheritance 45 Character 61
PlayerController 62
Managing Actors 46
Game Mode Base 64
Referencing Actors 46
Game Instance 66
Spawning and destroying Actors 51
Summary 66
Construction Script 54
Quiz 67
4
Understanding Blueprint Communication
Direct Blueprint Communication 70 Binding Events 90
Casting in Blueprints 76 Summary 93
Level Blueprint Communication 82 Quiz 94
Event Dispatchers 86
Part 2: Developing a Game
5
Object Interaction with Blueprints
Creating the project and the Material properties and nodes 102
first Level 98 Adding substance to our Material 105
Adding objects to our Level 99
Creating the target Blueprint 107
Exploring Materials 101
Detecting a hit 109
Creating Materials 101 Swapping a Material 110
Table of Contents vii
Improving the Blueprint 111 Getting relative speed using delta time 119
Updating location 120
Adding movement 113
Changing the Actor's Mobility and Changing direction 123
Collision settings 114 Testing moving targets 125
Breaking down our goal 115
Summary 126
Readying direction for calculations 118
Quiz 127
6
Enhancing Player Abilities
Adding the running Increasing the projectile's
functionality 130 speed 143
Breaking down the character Adding sound and
movement 130 particle effects 145
Customizing control inputs 134
Changing target states with branches 146
Adding a Sprint ability 136
Triggering sound effects, explosions,
and destruction 148
Animating a zoomed view 139
Using a timeline to smooth transitions 140 Summary 151
Quiz 152
7
Creating Screen UI Elements
Creating simple UI meters Creating bindings for health
with UMG 154 and stamina 171
Making text bindings for the ammo
Drawing shapes with Widget
and targets eliminated counters 173
Blueprints 156
Customizing the meter's appearance 159 Tracking the ammo and
Creating ammo and targets eliminated targets eliminated 174
counters 164
Reducing the ammo counter 174
Displaying the HUD 168
Increasing the targets
Connecting UI values eliminated counter 176
to player variables 170
Summary 177
Quiz 178
viii Table of Contents
8
Creating Constraints and Gameplay Objectives
Constraining player actions 180 Displaying a target goal in the HUD 202
Draining and regenerating stamina 181 Creating a win menu screen 204
Preventing firing actions when Displaying the WinMenu 210
out of ammo 195 Triggering a win 212
Creating collectible objects 196 Summary 214
Setting a gameplay Quiz 215
win condition 201
Part 3: Enhancing the Game
9
Building Smart Enemies with Artificial Intelligence
Setting up the enemy actor to Overlapping a patrol point 239
navigate 220 Running the Behavior Tree in
the AI Controller 241
Importing from the Marketplace 220
Teaching our AI to walk with the
Expanding the play area 221
Behavior Tree 242
Making the level traversable with a
Selecting the patrol points in the
NavMesh asset 227
BP_EnemyCharacter instance 246
Creating the AI assets 229
Setting up the BP_EnemyCharacter Making the AI chase the player 247
Blueprint 231
Giving the enemy sight with
Creating navigation behavior 233 PawnSensing 247
Creating a Behavior Tree Task 249
Setting up patrol points 233
Adding conditions to the Behavior Tree 251
Creating the Blackboard keys 234
Creating a chasing behavior 253
Creating the variables in BP_
EnemyCharacter 236
Summary 254
Updating the current patrol point key 237
Quiz 255
Table of Contents ix
10
Upgrading the AI Enemies
Creating an enemy attack 258 destructible 272
Making an attack task 258 Spawning more enemies
Using the attack task in the during gameplay 275
Behavior Tree 260
Creating the BP_EnemySpawner
Updating the health meter 261 blueprint 275
Making enemies hear and Creating enemy wandering
investigate sounds 263 behavior 278
Adding hearing to the Behavior Tree 263 Identifying a wander point with a
Setting up the investigating tasks 265 custom task 278
Creating variables and a macro to Adding wandering to the Behavior Tree
update the blackboard 266 280
Interpreting and storing the Last adjustments and test 281
noise Event data 268
Summary 283
Adding noise to the player's actions 270
Quiz 283
Making the enemies
11
Game States and Applying the Finishing Touches
Making danger real with Creating a transition screen to be
player death 286 shown between rounds 296
Transitioning to a new round when the
Setting up a lose screen 286
current round is won 299
Showing the lose screen 287
Pausing the game and
Creating round-based scaling
resetting the save file 301
with saved games 288
Creating a pause menu 301
Storing game information using the
Resuming the game 303
SaveGame class 289
Resetting the save file 304
Saving game information 290
Triggering the pause menu 305
Loading game information 293
Increasing the TargetGoal 294
Summary 307
Quiz 307