75,59 €
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.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 875
Veröffentlichungsjahr: 2022
Bring your game ideas to life using the new Unreal Engine 5 and C++
Gonçalo Marques
Devin Sherry
David Pereira
Hammad Fozi
BIRMINGHAM—MUMBAI
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.
Group Product Manager: Rohit Rajkumar
Publishing Product Manager: Nitin Nainani
Senior Editor: Aamir Ahmed
Senior Content Development Editor: Feza Shaikh
Technical Editor: Shubham Sharma
Copy Editor: Safis Editing
Project Coordinator: Manthan Patel
Proofreader: Safis Editing
Indexer: Rekha Nair
Production Designer: Prashant Ghare
Marketing Coordinator: Teny Thomas
First published: November 2020
Second edition: September 2022
Production reference: 1300822
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-80323-986-6
www.packt.com
I would like to dedicate this book to my parents and my girlfriend, who always supported my weird and uncertain game development journey.
– Gonçalo Marques
I would like to dedicate this book, and my involvement in its development, to all of my friends and family around the world. I love you all and would not be where I am today without your love, support, kindness, and inspiration. Thank you all.
– Devin Sherry
I would like to thank my girlfriend, my family, and all of my friends for inspiring and supporting me on this journey.
This book is dedicated to my grandmother Teresa (“E vai daí ós’pois...!”).
– David Pereira
I would like to dedicate this book to my mom, whose constant support and jolliness meant the world to me. I’m sure wherever she is right now, she’ll probably be proud looking at my accomplishments.
– Hammad Fozi
Gonçalo Marques has been an active gamer since the age of 6. He has been using Unreal Engine since 2016 and has done freelance and consulting work using the engine. Gonçalo also released a free and open source plugin called UI Navigation, which has garnered an extremely positive reception with over 100,000 downloads and is still receiving frequent updates and fixes. Thanks to the development of this plugin, he became an Epic MegaGrant recipient. He is now working at Funcom ZPX, a game studio in Lisbon that has contributed to games such as Conan Exiles, Mutant Year Zero, and Moons of Madness. Gonçalo is currently working on a new Funcom game in the Dune universe.
Devin Sherry is the principal technical designer at People Can Fly in Poland, having worked on Outriders and Outriders: Worldslayer using Unreal Engine 4. Before that, he worked on Aquanox: Deep Descent as a technical designer at the Digital Arrow studio in Serbia. With a decade of experience ranging from the Unreal Developers’ Kit to the newly released Unreal Engine 5, Devin is passionate about creating memorable experiences for players and bringing game mechanics to life.
David Pereira started making games in 1998 when he learned how to use Clickteam’s The Games Factory. He graduated in computer science from FCT-UNL, where he learned about C++, OpenGL, and DirectX, which allowed him to create more complex games. After working in IT consulting for a few years, he joined Miniclip in Portugal where he worked on popular mobile games such as 8 Ball Pool, Gravity Guy 1 and Gravity Guy 2, Extreme Skater, iStunt2, Hambo, and many others. Since then, he has been the lead developer for MPC in the John Lewis Christmas VR Experience, worked on an earlier version of Mortal Shell, and did volunteer work teaching people with Asperger’s how to make games with Unreal Engine 4. Today, he’s working on his own game, a soon-to-be-announced first-person action RPG.
Hammad Fozi comes from a gaming background and has been extensively working on Unreal Engine since 2017. He has been part of some very successful AAA projects such as Virtua FanCave (and Metaverse), Unnamed AAA Sci-Fi DJ Experience, Heroes and Generals, and Creed: Rise to Glory VR. Hammad has worked with teams who have had experience working at Ubisoft, Warner Bros. Games, 2K Games, and more! He has successfully helped teams consisting of 10–30 people to scale to 150+ in size over his very short yet impressive career. Hammad currently works as a senior C++ game developer and has extensive experience in working with VR and augmented reality, PC/PS5/Xbox/Android/iOS/macOS game development, and Web3/Metaverse/NFT systems (within Unreal Engine).
Lennard Fonteijn started BASIC programming in his early teens on an old DOS PC. He developed his skills over the years and programming was always a hobby. Being doubtful that turning his hobby into work would make him lose interest in programming, he decided to study computer science. At his first internship, he realized that programming websites and apps wasn’t what he wanted to do for long, so he decided to focus on his other passion besides programming: gaming. He was always fascinated by how games worked internally. Having spent quite some time fiddling around with libraries such as OpenGL and DirectX, he knew this had to become his specialty someday. As a result, he directed his computer science studies toward gaming by following a serious games-related ActionScript 3 class and also minoring in game technology. His final internship was at a local game company and he received his bachelor’s degree in 2013. After graduation, Lennard became the CTO of the company where he first interned and was a computer science lecturer at a university. In his spare time, he works on his own game-related projects.
Pranav Paharia is an experienced game programmer who has built gaming solutions with Unreal Engine and Unity3D. He has worked on single-player and multiplayer games, for various platforms such as mobile, PC, and VR. He has been working in the game industry since 2013. He has reviewed another book on Unreal Engine, Beginning Unreal Engine 4 Blueprints Visual Scripting. He has worked in various industry domains such as video games, animation, AEC, military, education, and social media. Pranav was keen on playing computer games in childhood. His love for computer games inspired him to make games, and he converted his passion into a profession. You can connect with him at [email protected].
Kacper Prędkiewicz, even though his main role is game design, is doing quite a lot of his work in Unreal Engine 5, giving him a unique view of how non-technical people work in Unreal Engine. He has been making games in engines such as Unity, Goodot, GameMaker, and Unreal Engine, and has worked on games of all kinds – from mobile games and small indie projects to big AAA games. He is a graduate in game design, a game designer at People Can Fly studios, and an avid beekeeper.
Thank you, Devin, for including me as your technical reviewer, and for everything you have taught me.
Immerse yourself in 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 the 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.
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.
Chapter 1, Introduction to Unreal Engine, explores the Unreal Engine editor. You will be introduced to the editor’s interface, see how to manipulate actors in a level, understand the basics of the blueprint visual scripting language, and discover how to create material assets that can then be used by meshes.
Chapter 2, Working with Unreal Engine, introduces Unreal Engine game fundamentals, along with how to create a C++ project and set up the Content Folder of projects. You’ll also be introduced to the topic of animations.
Chapter 3, Character Class Components and Blueprint Setup, introduces you to the Unreal Character class, along with the concept of object inheritance and how to work with input mappings.
Chapter 4, Getting Started with Player Input, introduces the topic of player input. You will learn how to associate a key press or a touch input with an in-game action, such as jumping or moving, through the use of action mappings and axis mappings.
Chapter 5, Query with Line Traces, starts a new project called Dodgeball. In this chapter, you will learn about the concept of line traces and the various ways in which they can be used in games.
Chapter 6, Setting Up Collision Objects, explores the topic of object collision. You will learn about collision components, collision events, and physics simulation. You will also study the topic of timers, the projectile movement component, and physical materials.
Chapter 7, Working with UE5 Utilities, teaches you how to implement some useful utilities available in Unreal Engine, including actor components, interfaces, and blueprint function libraries, which will help keep your projects well structured and approachable for other people that join your team.
Chapter 8, Creating User Interfaces with UMG, explores the topic of game UI. You will learn how to make menus and HUDs using Unreal Engine’s UI system, UMG, as well as how to display the player character’s health using a progress bar.
Chapter 9, Adding Audio-Visual Elements, introduces the topic of sounds and particle effects in Unreal Engine. You will learn how to import sound files to the project and use them as both 2D and 3D sounds, as well as how to add existing particle systems to the game. Lastly, a new level will be made that uses all the game mechanics built in the last few chapters to conclude the Dodgeball project.
Chapter 10, Creating the SuperSideScroller Game, discusses in detail the goals of the SuperSideScroller project and covers an overview of how animation works in Unreal Engine 5 through examples of manipulating the default Mannequin Skeleton.
Chapter 11, Working with Blend Space 1D, Key Bindings, and State Machines, teaches you how to use Blend Space 1D, Animation State Machines, and the Enhanced Input System in Unreal Engine 5 to create working movement-based animation logic for the player character.
Chapter 12, Animation Blending and Montages, discusses further animation concepts in Unreal Engine 5 such as Animation Blending and Animation Montages to allow for concurrent animation to occur when the player character moves and throws the projectile.
Chapter 13, Creating and Adding the Enemy Artificial Intelligence, teaches you how to use AI Controller, Blackboards, and Behavior Trees in Unreal Engine 5 to create simple AI logic for an enemy that the player can face.
Chapter 14, Spawning the Player Projectile, teaches you how to spawn and destroy game objects, and uses additional animation-based concepts such as Anim Notifies and Anim Notify states to spawn the player projectile during the throwing animation.
Chapter 15, Exploring Collectibles, Power-Ups, and Pickups, introduces you to UI concepts of UMG in Unreal Engine 5 and puts your knowledge to the test in creating additional collectibles and power-ups for the player.
Chapter 16, Getting Started with Multiplayer Basics, introduces you to multiplayer and how the server/client architecture works, as well as covering concepts such as connections, ownership, roles, and variable replication. It also covers 2D Blend Spaces to create an animation grid for 2D movement and the Transform Modify Bone control to change the transform of a bone at runtime.
Chapter 17, Using Remote Procedure Calls, teaches you how remote procedure calls work, the different types, and important considerations when using them. It also shows how to expose enumerations to the editor and how to use array index wrapping to cycle between an array in both directions.
Chapter 18, Using Gameplay Framework Classes in Multiplayer, explains how to use the most important classes in the Gameplay Framework in multiplayer. It also explains more about Game Mode, Player State, Game State, and some useful engine built-in functionality.
To access the files of the Unreal Engine GitHub repository linked throughout this book, make sure to follow these instructions:
https://www.unrealengine.com/en-US/ue-on-github
If you get an error 404 on a link from this book to the Unreal Engine documentation, it means that it hasn't been updated yet to 5.0. You should pick the previous engine version from the dropdown on the top left corner of the page.
Because we’ll be using C++ while working with Unreal Engine 5, we’ll need an Integrated Development Environment (IDE) that easily works alongside the engine. Visual Studio Community is the best IDE you have available for this purpose on Windows. If you’re using macOS or Linux, you’ll have to use another IDE, such as Visual Studio Code, Qt Creator, or Xcode (available exclusively on macOS).
The instructions given in this book are specific to Visual Studio Community on Windows, so if you are using a different OS and/or IDE, then you will need to do your research on how to set these up for use in your working environment. In this section, you’ll be taken through the installation of Visual Studio, so that you can easily edit UE5’s C++ files:
Go to the Visual Studio download web page at https://visualstudio.microsoft.com/downloads. The recommended Visual Studio Community version for the Unreal Engine 5 version we’ll be using in this book (5.0.3) is Visual Studio Community 2022. Be sure to download that version. When you do, open the executable file that you just downloaded. It should eventually take you to a window where you’ll be able to pick the modules of your Visual Studio installation. There, you’ll have to tick the Game Development with C++ module and then click the Install button in the bottom-right corner of the window. After you click that button, Visual Studio will start downloading and installing. When the installation is complete, it may ask you to reboot your PC. After rebooting your PC, Visual Studio should be installed and ready for use. When you run Visual Studio for the first time, you may see a few windows, the first one of which is the login window. If you have a Microsoft Outlook/Hotmail account, you should use that account to log in, otherwise, you can skip login by clicking Not now, maybe later.Note
If you don’t input an email address, you will only have 30 days to use Visual Studio before it locks out and you have to input an email address to continue using it.
After that, you will be asked to choose a color scheme. The Dark theme is the most popular and the one we will be using in this section.Finally, you can select the Start Visual Studio option. When you do so, however, you can close it again. We will be taking a deeper look at how to use Visual Studio in Chapter 2, Working with Unreal Engine of this book.
To access Unreal Engine 5, you’ll need to download the Epic Games Launcher, available at this link: https://store.epicgames.com/en-US/download.
Before you do so, be sure to check its hardware requirements at this link: https://docs.unrealengine.com/5.0/en-US/hardware-and-software-specifications-for-unreal-engine/.
This link will allow you to download the Epic Games Launcher for Windows and macOS. If you use Linux, you’ll have to download the Unreal Engine source code and compile it from the source – https://docs.unrealengine.com/5.0/en-US/downloading-unreal-engine-source-code/:
Click the Download Launcher option. A .msi file will be downloaded to your computer. Open this .msi file when it finishes downloading, which will prompt you to install the Epic Games Launcher. Follow the installation instructions and then launch the Epic Games Launcher. When you do so, you should be greeted with a login screen. If you already have an account, you can simply log in with your existing credentials. If you don’t, you’ll have to sign up for an Epic Games account by clicking the Sign Up text at the bottom.Once you log in with your account, you should be greeted by the Home tab. From there, you’ll want to go to the Unreal Engine tab by clicking the text that says Unreal Engine.
When you’ve done that, you’ll be greeted with the Store tab. The Epic Games Launcher is not only the place from which you install and launch Unreal Engine 5, but it’s also a game store. Press the Unreal Engine tab on the left side of the launcher.You will now find several sub-tabs at the top of the Epic Games Launcher, the first of which is the News sub-tab. This acts as a hub for Unreal Engine resources. From this page, you’ll be able to access the following: The News page, on which you’ll be able to take a look at all the latest Unreal Engine newsThe YouTube channel, on which you’ll be able to watch dozens of tutorials and live streams that go into detail about several different Unreal Engine topics The Q&A page, on which you’ll be able to see, ask, and answer questions posed and answered by the Unreal Engine communityThe Forums page, on which you’ll be able to access the Unreal Engine forumsThe Roadmap page, on which you’ll be able to access the Unreal Engine roadmap, including features delivered in past versions of the engine, as well as features that are currently in development for future versions The Samples tab will allow you to access several project samples that you can use to learn how to use Unreal Engine 5. To the right of the Samples tab is the Marketplace tab. This tab shows you several assets and code plugins made by members of the Unreal Engine community. Here, you’ll be able to find 3D assets, music, levels, and code plugins that will help you advance and accelerate the development of your game. To the right of the Marketplace tab, we have the Library tab. Here, you’ll be able to browse and manage all your Unreal Engine version installations, your Unreal Engine projects, and your Marketplace asset vault. Because we have none of these things yet, these sections are all empty. Let’s change that. Click the yellow plus sign to the right of the ENGINE VERSIONS text. This should make a new icon show up, where you’ll be able to choose your desired Unreal Engine version. Throughout this book, we’ll be using version 5.0 of Unreal Engine. After you’ve selected that version, click the Install button:Figure Preface 1.1 – The icon that allows you to install Unreal Engine 5.0
After you’ve done this, you’ll be able to choose the installation directory for this Unreal Engine version, which will be of your choosing, and you should then click the Install button again.Note
If you are having issues installing the 5.0 version, make sure to install it on your D drive, with the shortest path possible (that is, don’t try to install it too many folders deep, and make sure those folders have short names).
This will result in the installation of Unreal Engine 5.0 starting. When the installation is done, you can launch the editor by clicking the Launch button of the version icon:Figure Preface 1.2 – The version icon once installation has finished
If you are using the digital version of this book, we advise you to type the code yourself or access the code from the book’s GitHub repository (a link is available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.
You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/Elevating-Game-Experiences-with-Unreal-Engine-5-Second-Edition. If there’s an update to the code, it will be updated in the GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
You can download videos for Chapters 1, 3, 4-9, and 16-18 which will help to understand the chapters better. Here is the link for it: https://packt.link/1GnAS
We also provide a PDF file that has color images of the screenshots and diagrams used in this book. You can download it here: https://packt.link/iAmVj.
There are a number of text conventions used throughout this book.
Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: ”These lines of code represent the declarations of the Tick() and BeginPlay() functions that are included in every Actor-based class by default.”
A block of code is set as follows:
// Called when the game starts or when spawned void APlayerProjectile::BeginPlay() { Super::BeginPlay(); } // Called every frame void APlayerProjectile::Tick(float DeltaTime) { Super::Tick(DeltaTime); }Bold: Indicates a new term, an important word, or words that you see onscreen. For instance, words in menus or dialog boxes appear in bold. Here is an example: “From the Open Level dialog box, navigate to /ThirdPersonCPP/Maps to find SideScrollerExampleMap.”
Tips or Important Notes
Appear like this.
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book, email us at [email protected] and mention the book title in the subject of your message.
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata and fill in the form.
Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com
Once you’ve read Elevating Game Experiences 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.
Your review is important to us and the tech community and will help us make sure we’re delivering excellent quality content.
Welcome to Game Development Projects with Unreal Engine Second Edition. If this is the first time you’re using Unreal Engine 5 (UE5), this book will support you in getting started with one of the most in-demand game engines on the market. You will discover how to build up your game development skills and how to express yourself by creating video games. If you’ve already tried using UE5, this book will help you develop your knowledge and skills further so that you can build games more easily and effectively.
A game engine is a software application that allows you to produce video games from the ground up. Their feature sets vary significantly but usually allow you to import multimedia files, such as 3D models, images, audio, and video, and manipulate those files through the use of programming, where you can use programming languages such as C++, Python, and Lua, among others.
UE5 uses two main programming languages, C++ and Blueprint, with the latter being a visual scripting language that allows you to do most of what C++ also allows. Although we will be teaching a bit of Blueprint in this book, we will mostly focus on C++, and hence expect you to have a basic understanding of the language, including topics such as variables, functions, classes, inheritance, and polymorphism. We will remind you about these topics throughout this book where appropriate.
Examples of popular video games made with Unreal Engine 4, the previous Unreal Engine version that UE5 is heavily based on, include Fortnite, Final Fantasy VII Remake, Borderlands 3, Star Wars: Jedi Fallen Order, Gears 5, and Sea of Thieves, among many others. All of these have a very high level of visual fidelity, are well-known, and have (or had) millions of players.
The following link specifies some of the great games that have been made with Unreal Engine 5: https://youtu.be/kT4iWCxu5hA. This showcase will show you the variety of games that UE5 allows you to make, both in terms of visuals and gameplay style.
If you’d like to make games such as the ones shown in the video one day or contribute to them in any way, then you’ve taken your first step in that direction.
This chapter will be an introduction to the Unreal Engine editor. You will learn about the editor’s interface; how to add, remove, and manipulate objects in a level; how to use Unreal Engine’s Blueprint visual scripting language; and how to use materials in combination with meshes.
By the end of this chapter, you will be able to navigate the Unreal Engine editor, create Actors, manipulate them inside the level, and create materials. Let’s start this chapter by learning how to create a new UE5 project in this first exercise.
Note
Before you continue this chapter, make sure you have installed all the necessary software mentioned in the Preface.
The code files for this chapter can be found here: https://github.com/PacktPublishing/Elevating-Game-Experiences-with-Unreal-Engine-5-Second-Edition
In this first exercise, we will learn how to create a new UE5 project. UE5 has predefined project templates that allow you to implement a basic setup for your project. We’ll be using the Third Person template project in this exercise.
Follow these steps to complete this exercise:
After installing Unreal Engine version 5.0, launch the editor by clicking the Launch button next to the version icon.After you’ve done that, you’ll be greeted with the engine’s Projects window, which will show you the existing projects that you can open and work on. It will also give you the option to create a new project. Because we have no projects yet, the Recent Projects section will be empty. To create a new project, choose a Project Category option, which in our case will be Games. Then, click Next.After that, you’ll see the Project Templates window. This window will show all the available project templates in Unreal Engine. When creating a new project, instead of having that project start empty, you have the option to add some assets and code out of the box, which you can then modify to your liking. There are several project templates available for different types of games, but we’ll want to go with the Third Person project template in this case. Select that template and click the Next button, which should take you to the Project Settings window.In this window, you can choose a few options related to your project:
Blueprint or C++: Here, you can choose whether you want to be able to add C++ classes. The default option is Blueprint, but in our case, we’ll want to select the C++ option.Quality: Here, you can choose whether you want your project to have high-quality graphics or high performance. Set this option to Maximum Quality.Raytracing: Here, you can choose whether you want raytracing enabled or disabled. Raytracing is a novel graphics rendering technique that allows you to render objects by simulating the path of light (using light rays) over a digital environment. Although this technique is rather costly in terms of performance, it also provides much more realistic graphics, especially when it comes to lighting. Set it to disabled.Target Platforms: Here, you can choose the main platforms you’ll want this project to run on. Set this option to Desktop/Console.Starter Content: Here, you can choose whether you want this project to come with an additional set of basic assets. Set this option to With Starter Content.Location and Name: At the bottom of the window, you’ll be able to choose the location where your project will be stored on your computer and its name.Once you’ve made sure that all the options have been set to their intended values, click the Create Project button. This will cause your project to be created according to the parameters you set. It may take a few minutes for it to be ready. With that, you have created your first UE5 project!Now, let’s learn about some of the basics of UE5.
In this section, you will be introduced to the Unreal Engine editor, which is a fundamental topic for becoming familiar with UE5.
Once your project has been generated, you should see the Unreal Engine editor open automatically. This screen is likely the one that you will see the most when working with Unreal Engine, so you must get accustomed to it.
Let’s break down what we can see in the editor window:
Figure 1.1 – The Unreal Engine editor divided into its main windows
Let’s look at these windows in more detail:
Viewport: At the very center of the screen, you can see the Viewport window. This will show you the content of the current level and will allow you to navigate through your level as well as add, move, remove, and edit objects inside it. It also contains several different parameters regarding visual filters, object filters (which objects you can see), and the lighting on your level.Outliner: At the top-right corner of the screen, you’ll see the Outliner window. This allows you to quickly list and manipulate the objects that are on your level. The Viewport and Outliner windows work hand in hand in allowing you to manage your level, where the former will show you what it looks like and the latter will help you manage and organize it. The Outliner window allows you to organize the objects in your level in directories by showing you the objects in your level.Details: At the far right of the screen, below Outliner, you’ll be able to see the Details panel, which allows you to edit the properties of an object that you have selected in your level. Since no objects have been selected in the preceding screenshot, it is empty. However, if you select any object in your level by left-clicking on it, its properties should appear in this window, as shown in the following screenshot:Figure 1.2 – The Details tab
Toolbar: At the top of the screen, you’ll see the Toolbar area, where you’ll be able to save your current level, add objects to your level, and play your level, among other things.Note
We will only be using some of the buttons from these toolbars, namely, the Save Current, Settings, Add, and Play buttons.
Content Drawer: One of the windows that you’ll be using very frequently is the Content Drawer window. This window lets you quickly access the Context Browser window. You can also open it by using Ctrl + Space. The Content Browser window will let you browse and manipulate all the files and assets located inside your project’s folder. As mentioned at the start of this chapter, Unreal Engine allows you to import several types of multimedia files, and Content Browser is the window that will allow you to browse and edit them in their respective sub-editors. Whenever you create an Unreal Engine project, it will always generate a Content folder. This folder will be the root directory of the Content Browser window, meaning you can only browse files inside that folder. You can see the directory you’re currently browsing inside the Content Browser window by looking at the top of it, which, in our case, is Content | ThirdPersonCPP.Figure 1.3 – The Content Browser window shown in Unreal Editor interface
If you click the icon to the left of the Filters button, at the very left of the Content Browser window, you will be able to see the directory hierarchy of the Content folder. This directory view allows you to select, expand, and collapse individual directories in the Content folder of your project:
Figure 1.4 – The Content Browser window’s directory view
Note
The terms Content Drawer and Content Browser are interchangeable.
Now that we have learned about the main windows of the Unreal Engine editor, let’s look at how to manage those windows (hiding and showing their tabs).
As we’ve seen, the Unreal Engine editor is comprised of many windows, all of which are resizable, movable, and have a corresponding tab on top of them. You can click and hold a window’s tab and drag it to move it somewhere else. You can hide tab labels by right-clicking them and selecting the Hide Tabs option:
Figure 1.5 – How to hide a tab
If the tab labels have been hidden, you can get them to reappear by clicking the blue triangle in the top-left corner of that window, as shown in the following screenshot:
Figure 1.6 – The blue triangle that allows you to show a window’s tab
You can also dock the windows to the sidebar to hide them while also having them easily available:
Figure 1.7 – Docking a window to the sidebar
After that, to show or hide them, you simply have to click them:
Figure 1.8 – Showing a window docked to the sidebar
When it comes to the windows that are docked to the lower bar, such as the Content Drawer window, you can undock them from the lower bar into the editor by clicking Dock in Layout in the top-right corner:
Figure 1.9 – Undocking a window from the lower bar in the editor
Keep in mind that you can browse and open all the windows available in the editor, including the ones that were just mentioned, by clicking the Window button in the top-left corner of the editor.
Another very important thing you should know is how to play your level from inside the editor (also known as PIE). At the right edge of the Toolbar window, you’ll see the green Play button. If you click it, you’ll start playing the currently open level inside the editor:
Figure 1.10 – The green play button, alongside other game playback buttons
Once you hit Play, you’ll be able to control the player character in the level by using the W, A, S, and D keys to move the player character, the Spacebar to jump, and moving your mouse to rotate the camera:
Figure 1.11 – The level being played inside the editor
Then, you can press the Shift + Esc keys to stop playing the level.
Now that we’ve gotten accustomed to some of the editor’s windows, let’s take a deeper look at the Viewport window’s navigation.
In the previous section, we mentioned that the Viewport window allows you to visualize your level, as well as manipulate the objects inside it. Because this is a very important window for you to use and has a lot of functionality, we’re going to learn more about it in this section.
Before we start learning about the Viewport window, let’s quickly get to know levels. In UE5, levels represent a collection of objects, as well as their locations and properties. The Viewport window will always show you the contents of the currently selected level, which in this case was already made and generated alongside the Third Person template project. In this level, you can see four wall objects, one ground object, a set of stairs, and some other elevated objects, as well as the player character, which is represented by the UE5 mannequin. You can create multiple levels and switch between them by opening them via the Content Browser window.
To manipulate and navigate the currently selected level, you must use the Viewport window. If you press and hold the left mouse button inside the window, you’ll be able to rotate the camera horizontally by moving the mouse left and right, and move the camera forward and backward by moving the mouse forward and backward. You can achieve similar results by holding the right mouse button, except the camera will rotate vertically when you move the mouse forward and backward, which allows you to rotate the camera both horizontally and vertically.
Additionally, you can move around the level by clicking and holding the Viewport window with the right mouse button (the left mouse button works too, but using it for movement is not as useful due to there not being as much freedom when rotating the camera) and using the W and S keys to move forward and backward, the A and D keys to move sideways, and the E and Q keys to move up and down.
If you look at the top-right corner of the Viewport window, you will see a small camera icon with a number next to it, which will allow you to change the speed at which the camera moves in the Viewport window.
Another thing you can do in the Viewport window is change its visualization settings. You can change the type of visualization in the Viewport window by clicking the button that currently says Lit, which will show you all the options available for different lighting and other types of visualization filters.
If you click on the Perspective button, you’ll have the option to switch between seeing your level from a perspective view, as well as from an orthographic view, the latter of which may help you build your levels faster.
Now that we’ve learned how to navigate the viewport, let’s learn how to manipulate objects, also known as Actors, in your level.
In Unreal Engine, all the objects that can be placed in a level are referred to as Actors. In a movie, an actor would be a human playing a character, but in UE5, every single object you see in your level, including walls, floors, weapons, and characters, is an Actor.
Every Actor must have what’s called a Transform property, which is a collection of three things:
Location: A Vector property signifying the position of that Actor in the level in the X, Y, and Z-axis. A vector is simply a tuple with three floating-point numbers – one for the location of the point on each axis.Rotation: A Rotator property signifying the rotation of that Actor along the X, Y, and Z-axis. A rotator is also a tuple with three floating-point numbers – one for the angle of rotation on each axis.Scale: A Vector property signifying the scale (that is, the size) of that Actor in the level in the X, Y, and Z-axis. This is also a collection of three floating-point numbers – one for the scale value on each axis.Actors can be moved, rotated, and scaled in a level, which will modify their Transform property accordingly. To do this, select any object in your level by left-clicking on it. You should see the Move tool appear:
Figure 1.12 – The Move tool, which allows you to move an Actor in the level
The Move tool is a three-axis gizmo that allows you to move an object in any of the axes simultaneously. The red arrow of the Move tool (pointing to the left in the preceding screenshot) represents the X-axis, the green arrow (pointing to the right in the preceding screenshot) represents the Y-axis, and the blue arrow (pointing up in the preceding screenshot) represents the Z-axis. If you click and hold any of these arrows and then drag them around the level, you will move your Actor along that axis in the level. If you click the handles that connect two arrows, you will move the Actor along both those axes simultaneously, and if you click the white sphere at the intersection of all the arrows, you will move the Actor freely along all three axes:
Figure 1.13 – An Actor being moved on the Z-axis using the Move tool
The Move tool allows you to move an Actor around the level, but if you want to rotate or scale an Actor, you’ll need to use the Rotate and Scale tools, respectively. You can switch between the Move, Rotate, and Scale tools by pressing the W, E, and R keys, respectively. Press E to switch to the Rotate tool:
Figure 1.14 – The Rotate tool, which allows you to rotate an Actor
The Rotate tool, as expected, allows you to rotate an Actor in your level. You can click and hold any of the arcs to rotate the Actor around its associated axis. The red arc (top left in the preceding screenshot) will rotate the Actor around the X-axis, the green arc (top right in the preceding screenshot) will rotate the Actor around the Y-axis, and the blue arc (lower center in the preceding screenshot) will rotate the Actor around the Z-axis:
Figure 1.15 – A cube before and after being rotated 30 degrees around the Y-axis
Keep in mind that an object’s rotation around the X-axis is usually designated as Roll, its rotation around the Y-axis is usually designated as Pitch, and its rotation around the Z-axis is usually designated as Yaw.
Lastly, we have the Scale tool. Press R to switch to it:
Figure 1.16 – The Scale tool
The Scale tool allows you to increase and decrease the scale (size) of an Actor in the X, Y, and Z axes, where the red handle (left in the preceding screenshot) will scale the Actor on the X-axis, the green handle (right in the preceding screenshot) will scale the Actor on the Y-axis, and the blue handle (top in the preceding screenshot) will scale the Actor on the Z-axis:
Figure 1.17 – A Cube Actor before and after being scaled on all three axes
You can also toggle between the Move, Rotate, and Scale tools by clicking the following icons at the top of the Viewport window:
Figure 1.18 – The Move, Rotate, and Scale tool icons
Additionally, you can change the increments with which you move, rotate, and scale your objects through the grid snapping options to the right of the Move, Rotate, and Scale tool icons. By clicking the buttons highlighted in blue, you’ll be able to disable snapping altogether, and by pressing the buttons showing the current snapping increments, you’ll be able to change those increments:
Figure 1.19 – The grid-snapping icons for moving, rotating, and scaling
Now that you know how to manipulate Actors already present in your level, let’s learn how to add and remove Actors to and from our level.
In this exercise, we will be adding and removing Actors from our level.
When it comes to adding Actors to your level, there are two main ways in which you can do so: by dragging assets from the Content Browser window or by dragging the default assets from the Modes window’s Place Mode.
Follow these steps to complete this exercise:
Go to the ThirdPersonCPP | Blueprints directory inside the Content Browser window. Here, you will see the ThirdPersonCharacter Actor. If you drag that asset to your level using the left mouse button, you will be able to add an instance of that Actor to it. It will be placed wherever you let go of the left mouse button:Figure 1.20 – Dragging an instance of the ThirdPersonCharacter Actor to our level
Similarly, drag an Actor to your level by using the Add button in the Toolbar window (the cube with the green +):Figure 1.21 – Dragging a Cylinder Actor to our level
To delete an Actor, simply select the Actor and press the Delete key. You can also right-click on an Actor to look at the many other options available to you regarding that Actor.Note
Although we won’t be covering this topic in this book, one of the ways developers can populate their levels with simple boxes and geometry, for prototyping purposes, is BSP Brushes. These can be quickly molded into the desired shape as you build your levels. To find out more about BSP Brushes, go to https://docs.unrealengine.com/en-US/Engine/Actors/Brushes.
And with this, we have concluded this exercise and learned how to add and remove Actors to and from our level.
Now that we know how to navigate the Viewport window, let’s learn about Blueprint Actors.
In UE5, the word Blueprint can be used to refer to two different things: UE5’s visual scripting language or a specific type of asset, also referred to as a Blueprint class or Blueprint asset.
As we’ve mentioned previously, an Actor is an object that can be placed in a level. This object can either be an instance of a C++ class or an instance of a Blueprint class, both of which must inherit from the Actor class (either directly or indirectly). So, what is the difference between a C++ class and a Blueprint class, you may ask? There are a few:
If you add programming logic to your C++ class, you’ll have access to more advanced engine functionality than you would if you were to create a Blueprint class.In a Blueprint class, you can easily view and edit visual components of that class, such as a 3D mesh or a Trigger Box Collision, as well as modify properties defined in the C++ class that are exposed to the editor, which makes managing those properties much easier.In a Blueprint class, you can easily reference other assets in your project, whereas in C++, you can also do so but less simply and less flexibly.Programming logic that runs on Blueprint visual scripting is slower in terms of performance than that of a C++ class.It’s simple to have more than one person work on a C++ class simultaneously without conflicts in a source version platform, whereas with a Blueprint class, which is interpreted as a binary file instead of a text file, conflicts will occur in your source version platform if two different people edit the same Blueprint class.Note
If you don’t know what a source version platform is, this is how several developers can work on the same project and have it updated with the work done by other developers. In these platforms, different people can usually edit the same file simultaneously, so long as they edit different parts of that file, and still receive updates that other programmers made without them affecting your work on that same file. One of the most popular source version platforms is GitHub.
Keep in mind that Blueprint classes can inherit either from a C++ class or from another Blueprint class.
