Reader small image

You're reading from  Game Development Projects with Unreal Engine

Product typeBook
Published inNov 2020
Reading LevelBeginner
PublisherPackt
ISBN-139781800209220
Edition1st Edition
Languages
Tools
Right arrow
Authors (4):
Hammad Fozi
Hammad Fozi
author image
Hammad Fozi

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).
Read more about Hammad Fozi

Gonçalo Marques
Gonçalo Marques
author image
Gonçalo Marques

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.
Read more about Gonçalo Marques

David Pereira
David Pereira
author image
David Pereira

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.
Read more about David Pereira

Devin Sherry
Devin Sherry
author image
Devin Sherry

Devin Sherry is originally from Levittown, NY, located on Long Island. He studied the topics of Game Development and Game Design at the University of Advancing Technology where he had earned his Bachelor of Arts in Game Design in 2012. During his time in college, Devin worked as a game and level designer with a group of students called Autonomous Games on a real-time strategy styled, third-person shooter called The Afflicted using Unreal Engine 3/UDK where it was presented at GDC in 2013 at the GDC Play Showcase. Today, Devin works as an independent game developer located in Tempe, Arizona, where he works on personal and contracted projects. His achievements include the title Radial Impact, which can be found in the Community Contributions section of the Learn Tab of Unreal Engine 4's Launcher, and his work on his YouTube Channel, Devin Level Design, where he educates viewers on game development within Unreal Engine 3, UDK, and Unreal Engine 4.
Read more about Devin Sherry

View More author details
Right arrow

1. Unreal Engine Introduction

Overview

This chapter will be an introduction to the Unreal Engine editor. You will get to know 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 your own Actors, manipulate them inside the level, and create materials.

Introduction

Welcome to Game Development Projects with Unreal Engine. If this is the first time you're using Unreal Engine 4 (UE4), 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 through the creation of your own video games. If you've already tried using UE4, this book will help you further develop your knowledge and skills, so 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.

Unreal Engine 4 uses two main programming languages, C++ and Blueprint, the latter...

Getting to Know Unreal

You will now be introduced to the Unreal Engine editor, which is a fundamental topic to get familiar with Unreal Engine 4.

When your project has finished generating, 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 it is important that you get accustomed to it.

Let's break down what we see in the editor window:

Figure 1.1: The Unreal Engine editor divided in its six main windows

  1. Content Browser: The window that occupies the majority of the bottom of the screen is the Content Browser. This window will let you browse and manipulate all the files and assets located inside your project's folder. As was mentioned at the start of the chapter, Unreal Engine will allow 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...

Editor Windows

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 in order to move it somewhere else. You can hide tab labels by right-clicking them and selecting the Hide 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 yellow triangle at the top-left corner of that window, as shown in the following figure:

Figure 1.6: The yellow triangle that allows you to show a window's tab

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...

Viewport Navigation

We mentioned in the previous section that the Viewport window will allow you to visualize your level, as well as manipulating 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 about Levels. In UE4, 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 was generated alongside the Third Person template project. In this level, you'll be able to see four wall objects, one ground object, a set of stairs, and some other elevated objects, as well as the player character represented by the UE4 mannequin. You can create multiple levels and switch between them by opening them from Content Browser.

In order to...

Manipulating Actors

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 UE4, 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 in 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 in each axis.
  • Scale: A Vector property signifying the scale (meaning size) of that Actor in the level in the X, Y, and Z axis. This is also a collection of three floating point numbers...

Blueprint Actors

In UE4, the word Blueprint can be used to refer to two different things: UE4's visual scripting language or a specific type of asset, also referred to as a Blueprint class or Blueprint asset.

As we've mentioned before, 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 modifying properties defined in the C++ class that is exposed to the editor, which makes managing...

The Blueprint Editor

The Blueprint editor is a sub-editor within the Unreal Engine editor specifically for Blueprint classes. Here, you'll be able to edit the properties and logic for your Blueprint classes, or those of their parent class, as well as their visual appearance.

When you open an Actor Blueprint class, you should see the Blueprint editor. This is the window that will allow you to edit your Blueprint classes in UE4. Let's learn about the windows that you're currently seeing:

Figure 1.20: The Blueprint editor window is broken down into five parts

  1. Viewport: Front and center in the editor you have the Viewport window. This window, similar to the Level Viewport window that we already learned about, will allow you to visualize your Actor and edit its components. Every actor can have several Actor Components, some of which have a visual representation, such as Mesh Components and Collision Components. We'll be talking about...

Event Graph

The Event Graph window is where you'll be writing all of your Blueprint visual scripting code, creating your variables and functions, and accessing other variables and functions declared in this class's parent class.

If you select the Event Graph tab, which you should be able to see to the right of the Viewport tab, you will be shown the Event Graph window instead of the Viewport window. On clicking the Event Graph tab, you will have the following window:

Figure 1.21: The Event Graph window, showing three disabled events

You can navigate the Event Graph by holding the right mouse button and dragging inside the graph, you can zoom in and out by scrolling the mouse wheel, and you can select nodes from the graph by either clicking with the left mouse button or by pressing and holding to select an area of nodes.

You can also right-click inside the Event Graph window to access the Blueprint's Actions menu, which allows you to...

The Float Multiplication Node

Blueprint contains many more nodes that are not related to variables or functions. One such example is arithmetic nodes (that is adding, subtracting, multiplying, and so on.). If you search for float * float on the Blueprint Actions menu, you'll find the Float Multiplication node:

Figure 1.36: The Float Multiplication node

This node allows you to input two or more float parameters (you can add more by clicking the + icon to the right of the Add pin text) and output the result of the multiplication of all of them. We will be using this node later, in this chapter's activity.

BeginPlay and Tick

Let's now take a look at two of the most important events in UE4: BeginPlay and Tick.

As mentioned previously, events will usually be called from outside the Blueprint class. In the case of the BeginPlay event, this event gets called either when an instance of this Blueprint class is placed in the level and the level starts being played, or when an instance of this Blueprint class is spawned dynamically while the game is being played. You can think of the BeginPlay event as the first event that will be called on an instance of this Blueprint, which you can use for initialization.

The other important event to know about in UE4 is the Tick event. As you may know, games run at a certain frame rate, the most frequent being either 30 FPS (frames per second) or 60 FPS: this means that the game will render an updated image of the game 30 or 60 times every second. The Tick event will get called every time the game does this, which means that if the game is...

ThirdPersonCharacter Blueprint Class

Let's take a look at the ThirdPersonCharacter Blueprint class, which is the Blueprint representing the character that the player controls, and take a look at the Actor Components that it contains.

Go to the ThirdPersonCPP -> Blueprints directory inside Content Browser and open the ThirdPersonCharacter asset:

Figure 1.44: The ThirdPersonCharacter Blueprint class

In a previous section, where we introduced the Components window inside the Blueprint editor, we mentioned Actor Components.

Actor Components are entities that must live inside an Actor and allow you to spread the logic of your Actor into several different Actor Components. In this Blueprint, we can see that there are four visually represented Actor Components:

  • A Skeletal Mesh Component, which shows the UE4 mannequin
  • A Camera Component, which shows where the player will be able to see the game from
  • An Arrow Component, which allows us...

Meshes and Materials

For a computer to visually represent a 3D object, it needs two things: a 3D mesh and a material.

Meshes

3D meshes allow you to specify the size and shape of an object, like this mesh representing a monkey's head:

Figure 1.45: A 3D mesh of a monkey's head

Meshes are comprised of several vertices, edges, and faces. Vertices are simply a 3D coordinate with an X, Y, and Z position; an edge is a connection (that is, a line) between two vertices; and a face is a connection of three or more edges. You can see in the previous figure the individual vertices, edges, and faces of the mesh, where each face is colored between white and black, depending on how much light is reflecting off the face. Nowadays, video games can render meshes with thousands of vertices in such a way that you can't tell the individual vertices apart because there are so many of them so close together.

Materials

Materials, on the other hand, allow...

Manipulating Materials in UE4

In this section, we'll be taking a look at how materials work in UE4.

Go back to your Level Viewport window and select this Cube object:

Figure 1.46: The Cube object, next to the text saying Third Person on the floor

Take a look at the Details window, where you'll be able to see both the mesh and material associated with this object's Static Mesh component:

Figure 1.47: The Static Mesh and Materials (Element 0) properties of the Cube object's Static Mesh component

Note

Keep in mind that meshes can have more than one material, but must have at least one.

Click the looking glass icon next to the Material property to be taken to that material's location in Content Browser. This icon works with any reference to any asset inside the editor, so you can do the same thing with the asset referenced as the cube object's Static Mesh:

Figure 1.48: The looking...

Summary

By completing this chapter, you have taken the first step in your game development journey by learning about Unreal Engine 4. You now know how to navigate the Unreal Engine editor, manipulate the Actors inside a level, create your own Actors, use the Blueprint scripting language, and how 3D objects are represented in Unreal Engine 4.

Hopefully, you realize that there's a whole world of possibilities ahead of you and that the sky is the limit in terms of the things you can create using this game development tool.

In the next chapter, you will recreate the project template that was automatically generated in this chapter from scratch. You will learn how to create your own C++ classes and then create Blueprint classes that can manipulate properties declared in their parent class and how to import character meshes and animations into Unreal Engine 4, as well as becoming familiar with other animation-related assets such as Animation Blueprints.

...
lock icon
The rest of the chapter is locked
You have been reading a chapter from
Game Development Projects with Unreal Engine
Published in: Nov 2020Publisher: PacktISBN-13: 9781800209220
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (4)

author image
Hammad Fozi

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).
Read more about Hammad Fozi

author image
Gonçalo Marques

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.
Read more about Gonçalo Marques

author image
David Pereira

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.
Read more about David Pereira

author image
Devin Sherry

Devin Sherry is originally from Levittown, NY, located on Long Island. He studied the topics of Game Development and Game Design at the University of Advancing Technology where he had earned his Bachelor of Arts in Game Design in 2012. During his time in college, Devin worked as a game and level designer with a group of students called Autonomous Games on a real-time strategy styled, third-person shooter called The Afflicted using Unreal Engine 3/UDK where it was presented at GDC in 2013 at the GDC Play Showcase. Today, Devin works as an independent game developer located in Tempe, Arizona, where he works on personal and contracted projects. His achievements include the title Radial Impact, which can be found in the Community Contributions section of the Learn Tab of Unreal Engine 4's Launcher, and his work on his YouTube Channel, Devin Level Design, where he educates viewers on game development within Unreal Engine 3, UDK, and Unreal Engine 4.
Read more about Devin Sherry