Elevating Game Experiences with Unreal Engine 5 - Second Edition

Book description

Get hands-on with game development tools and techniques in this illustrated guide to build a game project using the latest version of Unreal Engine and C++, two of the most widely used tools in the game industry

Key Features

  • Kickstart your career or develop a new hobby by learning game development with Unreal Engine 5 and C++
  • Learn techniques to prototype and develop your own ideas with key images printed in color
  • Reinforce your skills with project-based learning by building a series of games from scratch

Book Description

Immerse yourself in the Unreal game projects with this book, written by four highly experienced industry professionals with many years of combined experience with Unreal Engine. Elevating Game Experiences with Unreal Engine 5 will walk you through the latest version of Unreal Engine by helping you get hands-on with the game creation projects.

The book starts with an introduction to the Unreal Editor and key concepts such as actors, blueprints, animations, inheritance, and player input. You'll then move on to the first of three projects, building a dodgeball game, where you'll learn the concepts of line traces, collisions, projectiles, user interface, and sound effects. You’ll also discover how to combine these concepts to showcase your new skills. The second project, a side-scroller game, will help you implement concepts such as animation blending, enemy AI, spawning objects, and collectibles. And finally, you'll cover the key concepts in creating a multiplayer environment as you work on the third project, an FPS game.

By the end of this Unreal Engine book, you'll have a broad understanding of how to use the tools that the game engine provides to start building your own games.

What you will learn

  • Create a fully functional third-person character and enemies
  • Implement navigation with keyboard, mouse, and gamepad
  • Program logic and game mechanics with collision and particle effects
  • Explore AI for games with Blackboards and behavior trees
  • Build character animations with animation blueprints and montages
  • Polish your game with stunning visual and sound effects
  • Explore the fundamentals of game UI using a heads-up display
  • Discover how to implement multiplayer in your games

Who this book is for

This book is for game developers looking to get started with using Unreal Engine 5 for their game development projects. Anyone who has used Unreal Engine before and wants to consolidate, improve, and apply their skills will find this book useful. To better grasp the concepts explained in this book, prior knowledge of C++ basics such as variables, functions, classes, polymorphism, and pointers is required. For full compatibility with the IDE used in this book, a Windows system is recommended

Table of contents

  1. Elevating Game Experiences with Unreal Engine 5
  2. Second Edition
  3. Contributors
  4. About the authors
  5. About the reviewers
  6. Preface
    1. Who this book is for
    2. What this book covers
      1. To get the most out of this book
      2. Installing Visual Studio
      3. Epic Games Launcher
    3. Download the example code files
    4. Download the color images
    5. Conventions used
    6. Get in touch
    7. Share Your Thoughts
  7. Chapter 1: Introduction to Unreal Engine
    1. Technical requirements
    2. Exercise 1.01 – creating an Unreal Engine 5 project
    3. Getting to know Unreal Engine
    4. Exploring editor windows
    5. Viewport navigation
    6. Manipulating Actors
      1. Exercise 1.02 – adding and removing Actors
    7. Understanding Blueprint Actors
      1. Exercise 1.03 – creating Blueprint Actors
    8. Exploring the Blueprint editor
    9. Exploring the Event Graph window
      1. Exercise 1.04 – creating Blueprint variables
      2. Exercise 1.05 – creating Blueprint functions
    10. Understanding the Multiply node
    11. Exploring the BeginPlay and Tick events
      1. Exercise 1.06 – offsetting the TestActor class on the Z-axis
    12. The ThirdPersonCharacter Blueprint class
    13. Exploring the usage of meshes and materials
      1. Meshes
      2. Materials
    14. Manipulating materials in UE5
    15. Activity 1.01 – propelling TestActor on the Z-axis indefinitely
    16. Summary
  8. Chapter 2: Working with Unreal Engine
    1. Technical requirements
    2. Creating and setting up a blank C++ project
      1. Exercise 2.01 – creating an empty C++ project
    3. The Content folder’s structure in Unreal Engine
    4. Working with the Visual Studio solution
      1. Debugging code in Visual Studio
      2. Exercise 2.02 – debugging the Third Person template code
    5. Importing the required assets
      1. Exercise 2.03 – importing a character FBX file
    6. The Unreal Game Mode class
      1. Game Mode default classes
      2. Gameplay events
      3. Networking
      4. GameModeBase versus Game Mode
    7. Understanding levels and the Level Blueprint
      1. The Unreal Pawn class
      2. The Unreal Player Controller class
      3. Exercise 2.04 – setting up the Game Mode, Player Controller, and Pawn classes
    8. Working with animations
      1. Animation Blueprints
      2. Event Graph
      3. The Anim Graph
      4. State Machines
      5. Transition Rules
      6. Blend Spaces
      7. Activity 2.01 – linking animations to a character
    9. Summary
  9. Chapter 3: Character Class Components and Blueprint Setup
    1. Technical requirements
    2. The Unreal Character class
    3. Extending the C++ class with Blueprints
    4. Summary
  10. Chapter 4: Getting Started with Player Input
    1. Technical requirements
    2. Understanding Input Actions and Contexts
      1. Exercise 4.01 – creating the movement and jump input actions
    3. Processing Player Input
      1. Exercise 4.02 – listening to movement and jump input actions
    4. Turning the camera around the character
    5. Activity 4.01 – adding walking logic to our character
    6. Summary
  11. Chapter 5: Query with Line Traces
    1. Technical requirements
    2. Introduction to collision
    3. Setting up your project
      1. Exercise 5.01: Converting DodgeballCharacter to a top-down perspective
    4. Understanding Line Traces
    5. Creating the EnemyCharacter C++ class
      1. Exercise 5.02: Creating the CanSeeActor function that executes Line Traces
    6. Visualizing the Line Trace
      1. Exercise 5.03: Creating the LookAtActor function
    7. Creating the EnemyCharacter Blueprint Class
    8. Sweep Traces
      1. Exercise 5.04: Executing a Sweep Trace
      2. Changing the Visibility Trace Response
      3. Multi Line Traces
      4. The Camera Trace Channel
      5. Exercise 5.05: Creating a custom EnemySight Trace Channel
      6. Activity 5.01: Creating the SightSource property
    9. Summary
  12. Chapter 6: Setting Up Collision Objects
    1. Technical requirements
    2. Understanding object collision in UE5
    3. Understanding collision components
    4. Understanding collision events
    5. Understanding collision channels
      1. Exercise 6.01 – creating the Dodgeball class
    6. Creating Physical Materials
      1. Exercise 6.02 – adding a ProjectileMovementComponent to DodgeballProjectile
    7. Introducing timers
    8. Understanding how to spawn actors
      1. Exercise 6.03 – adding projectile-throwing logic to the EnemyCharacter class
    9. Creating the Wall classes
      1. Exercise 6.04 – creating Wall classes
    10. Creating the VictoryBox actor
      1. Exercise 6.05 – creating the VictoryBox class
      2. Exercise 6.06 – adding the ProjectileMovementComponent getter function to DodgeballProjectile
      3. Activity 6.01 – replacing the SpawnActor function with SpawnActorDeferred in EnemyCharacter
    11. Summary
  13. Chapter 7: Working with UE5 Utilities
    1. Technical requirements
    2. Good practices – loose coupling
    3. Blueprint Function Libraries
      1. Exercise 7.01 – moving the CanSeeActor function to the Blueprint Function Library
    4. Actor components
      1. Exercise 7.02 – creating the HealthComponent Actor component
      2. Exercise 7.03 – integrating the HealthComponent Actor component
    5. Exploring interfaces
    6. Blueprint native events
      1. Exercise 7.04 – creating the HealthInterface class
      2. Activity 7.01 – moving the LookAtActor logic to an Actor component
    7. Summary
  14. Chapter 8: Creating User Interfaces with UMG
    1. Technical requirements
    2. Game UI
    3. UMG basics
      1. Exercise 8.01 – creating a Widget Blueprint
    4. Introducing anchors
      1. Exercise 8.02 – editing UMG anchors
      2. Exercise 8.03 – creating the RestartWidget C++ class
      3. Exercise 8.04 – creating the logic for adding the RestartWidget class to the screen
      4. Exercise 8.05 – setting up the DodgeballPlayerController blueprint class
    5. Understanding progress bars
      1. Exercise 8.06 – creating the health bar C++ logic
      2. Activity 8.01 – improving the RestartWidget class
    6. Summary
  15. Chapter 9: Adding Audio-Visual Elements
    1. Technical requirements
    2. Audio in UE5
      1. Exercise 9.01 – Importing an audio file
      2. Exercise 9.02 – Playing a sound when the dodgeball bounces off a surface
    3. Sound attenuation
      1. Exercise 9.03 – Turning the bounce sound into a 3D sound
      2. Exercise 9.04 – Adding background music to our game
    4. Understanding Particle Systems
      1. Exercise 9.05 – Spawning a Particle System when the dodgeball hits the player
      2. Activity 9.01 – Playing a sound when the dodgeball hits the player
    5. Exploring level design
      1. Exercise 9.06 – Building a level blockout
    6. Extra features
    7. Summary
  16. Chapter 10: Creating the SuperSideScroller Game
    1. Technical requirements
    2. Project breakdown
    3. The player character
    4. Converting the Third Person template into a side-scroller
      1. Exercise 10.01 – Creating the side-scroller project and using the Character Movement component
      2. Activity 10.01 – Making our character jump higher
    5. Exploring the features of our side-scroller game
      1. Enemy character
      2. Power-ups
      3. Collectibles
      4. Heads-Up Display (HUD)
      5. Exercise 10.02 – Exploring the Persona Editor and manipulating the default mannequin skeleton weights
      6. Activity 10.02 – Skeletal bone manipulation and animations
    6. Understanding animations in Unreal Engine 5
      1. Skeletons
      2. Skeletal Meshes
      3. Animation sequences
      4. Exercise 10.03 – Importing and setting up the character and animation
      5. Activity 10.03 – Importing more custom animations to preview the character running
    7. Summary
  17. Chapter 11: Working with Blend Space 1D, Key Bindings, and State Machines
    1. Technical requirements
    2. Creating Blend Spaces
      1. Blend Space 1D versus normal Blend Space
      2. Exercise 11.01 – creating the CharacterMovement Blend Space 1D
      3. Activity 11.01 – adding the Walking and Running animations to the Blend Space
    3. The Main Character Animation Blueprint
      1. Animation Blueprints
      2. Exercise 11.02 – adding the Blend Space to the character Animation Blueprint
    4. What are velocity vectors?
      1. Exercise 11.03 – passing the character’s Speed variable into the Blend Space
      2. Activity 11.02 – previewing the Running animation in-game
    5. Enhanced input system
      1. Exercise 11.04 – adding input for sprinting
      2. Exercise 11.05 – reparenting the character Blueprint
      3. Exercise 11.06 – coding the character’s sprint functionality
      4. Activity 11.03 – implementing the throwing input
    6. Using Animation State Machines
      1. Exercise 11.07 – player character movement and jump state machine
      2. Transition rules
      3. Exercise 11.08 – adding states and transition rules to the state machine
      4. Exercise 11.09 – The Time Remaining Ratio function
      5. Activity 11.04 – finishing the Movement and Jumping state machines
    7. Summary
  18. Chapter 12: Animation Blending and Montages
    1. Technical requirements
    2. Animation blending, Anim Slots, and Animation Montages
      1. Exercise 12.01 – Setting up the Animation Montage
    3. Animation Montages
      1. Exercise 12.02 – Adding the Throw animation to the montage
    4. Anim Slot Manager
      1. Exercise 12.03 – Adding a new Anim Slot
    5. Save Cached Pose
      1. Exercise 12.04 – Save Cached Pose of the Movement State Machine
    6. Layered blend per bone
      1. Exercise 12.05 – Blending animation with the Upper Body Anim Slot
      2. Exercise 12.06 – Previewing the Throw animation
    7. The SuperSideScroller game enemy
      1. Exercise 12.07 – Creating the enemy base C++ class
      2. Exercise 12.08 – Creating and applying the enemy Animation Blueprint
    8. Materials and Material Instances
      1. Exercise 12.09 – Creating and applying the enemy Material Instance
      2. Activity 12.01 – Updating Blend Weights
    9. Summary
  19. Chapter 13: Creating and Adding the Enemy Artificial Intelligence
    1. Technical requirements
    2. Enemy AI
    3. AI Controller
      1. Auto Possess AI
      2. Exercise 13.01 – implementing AI Controllers
    4. Navigation Mesh
      1. Exercise 13.02 – implementing a Nav Mesh Volume for the AI enemy
    5. Recasting the Nav Mesh
      1. Exercise 13.03 – recasting Nav Mesh Volume parameters
      2. Activity 13.01 – creating a new level
    6. Behavior trees and Blackboards
      1. Tasks
      2. Decorators
      3. Services
      4. Exercise 13.04 – creating the AI behavior tree and Blackboard
      5. Exercise 13.05 – creating a new behavior tree task
      6. Exercise 13.06 – creating the behavior tree logic
      7. Activity 13.02 – AI moving to the player’s location
      8. Exercise 13.07 – creating the enemy patrol locations
    7. Vector Transformation
      1. Exercise 13.08 – selecting a random point in an array
      2. Exercise 13.09 – referencing the patrol point actor
      3. Exercise 13.10 – updating BTTask_FindLocation
    8. Player projectile
      1. Exercise 13.11 – creating the player projectile
      2. Exercise 13.12 – initializing the PlayerProjectile class’s settings
      3. Activity 13.03 – creating the player projectile Blueprint
    9. Summary
  20. Chapter 14: Spawning the Player Projectile
    1. Anim Notifies and Anim Notify States
      1. Exercise 14.01 – creating a UAnimNotify class
      2. Exercise 14.02 – adding the new notify to the Throw Animation Montage
    2. Playing Animation Montages
      1. Playing Animation Montages in Blueprints
      2. Playing Animation Montages in C++
      3. Exercise 14.03 – playing the Throw animation in C++
      4. Exercise 14.04 – creating the projectile spawn socket
      5. Exercise 14.05 – preparing the SpawnProjectile() Function
      6. Exercise 14.06 – updating the Anim_ProjectileNotify class
    3. Destroying actors
      1. Exercise 14.07 – creating the DestroyEnemy() function
      2. Exercise 14.08 – destroying projectiles
      3. Activity 14.01 – Allow the projectile to destroy enemies
    4. Understanding and implementing visual and audio effects
      1. VFX
      2. Audio effects (SFX)
      3. Exercise 14.09 – adding effects when the enemy is destroyed
      4. Exercise 14.10 – adding effects to the player projectile
      5. Exercise 14.11 – adding VFX and SFX notifies
      6. Activity 14.02 – adding effects for when the projectile is destroyed
    5. Summary
  21. Chapter 15: Exploring Collectibles, Power-Ups, and Pickups
    1. Technical requirements
    2. Understanding URotatingMovementComponent
      1. Exercise 15.01 – creating the PickableActor_Base class and adding URotatingMovementComponent
      2. Activity 15.01 – player overlap detection and spawning effects in PickableActor_Base
      3. Activity 15.02 – finalizing the PickableActor_Collectable actor
    3. Logging variables using UE_LOG
      1. Exercise 15.03 – tracking the number of coins for the player
    4. Introducing Unreal Motion Graphics UI
    5. Understanding the Text widget
      1. Anchors
      2. Text formatting
      3. Exercise 15.04 – creating the Coin Counter UI HUD element
    6. Adding and creating UMG user widgets
      1. Exercise 15.05 – Adding Coin Counter UI to the player screen
    7. Using timers
      1. Exercise 15.06 – adding the potion power-up behavior to the player
      2. Activity 15.03 – creating the potion power-up actor
      3. Exercise 15.07 – creating the Brick class
      4. Exercise 15.08 – adding the Brick class’s C++ logic
    8. Summary
    9. Additional Challenges
  22. Chapter 16: Getting Started with Multiplayer Basics
    1. Technical requirements
    2. Introduction to multiplayer basics
    3. Understanding the server
      1. Dedicated server
      2. The listen server
    4. Understanding the client
      1. Exercise 16.01 – Testing the Third Person template in multiplayer
    5. Packaging the project
    6. Exploring connections and ownership
    7. Getting to know roles
      1. Actor spawned on the server
      2. Actor spawned on the client
      3. Player-owned pawn spawned on the server
      4. Player-owned pawn spawned on the client
      5. Exercise 16.02 – Implementing ownership and roles
      6. Output for the Server window
      7. Server Character
      8. Client 1 Character
      9. The OwnershipTest actor
      10. Output for the Client 1 window
    8. Understanding variable replication
      1. Replicated variables
      2. Exercise 16.03 – Replicating variables using Replicated, ReplicatedUsing, DOREPLIFETIME, and DOREPLIFETIME_CONDITION
      3. Output for the Server window
      4. Output for the Client 1 window
    9. Exploring 2D Blend Spaces
      1. Exercise 16.04 – Creating a movement 2D Blend Space
    10. Transforming (modifying) bones
      1. Exercise 16.05 – Creating a character that looks up and down
    11. Activity 16.01 – Creating the character for the multiplayer FPS project
    12. Summary
  23. Chapter 17: Using Remote Procedure Calls
    1. Technical requirements
    2. Understanding remote procedure calls
      1. Server RPC
      2. Multicast RPC
      3. Client RPC
      4. Important considerations when using RPCs
      5. Exercise 17.01 – Using remote procedure calls
    3. Exposing enumerations to the editor
      1. TEnumAsByte
      2. UMETA
      3. BlueprintType
      4. Exercise 17.02 – Using C++ enumerations in the editor
    4. Using array index wrapping
      1. Exercise 17.03 – Using array index wrapping to cycle between an enumeration
    5. Activity 17.01 – Adding weapons and ammo to the multiplayer FPS game
    6. Summary
  24. Chapter 18: Using Gameplay Framework Classes in Multiplayer
    1. Technical requirements
    2. Accessing Gameplay Framework Instances in Multiplayer
      1. Exercise 18.01 – Displaying the Gameplay Framework instance values
      2. Output for the Server window
      3. Output for the Client 1 window
      4. Game mode
      5. Player state
      6. Game State
      7. Useful built-in functionality
      8. Exercise 18.02 – Making a simple multiplayer pickup game
    3. Activity 18.01 – Adding death, respawning, a scoreboard, kill limit, and pickups to the multiplayer FPS game
    4. Summary
  25. Index
    1. Why subscribe?
  26. Other Books You May Enjoy
    1. Packt is searching for authors like you

Product information

  • Title: Elevating Game Experiences with Unreal Engine 5 - Second Edition
  • Author(s): Gonçalo Marques, Devin Sherry, David Pereira, Hammad Fozi
  • Release date: September 2022
  • Publisher(s): Packt Publishing
  • ISBN: 9781803239866