Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Game Development Projects with Unreal Engine

You're reading from  Game Development Projects with Unreal Engine

Product type Book
Published in Nov 2020
Publisher Packt
ISBN-13 9781800209220
Pages 822 pages
Edition 1st Edition
Languages
Authors (4):
Hammad Fozi Hammad Fozi
Profile icon Hammad Fozi
Gonçalo Marques Gonçalo Marques
Profile icon Gonçalo Marques
David Pereira David Pereira
Profile icon David Pereira
Devin Sherry Devin Sherry
Profile icon Devin Sherry
View More author details

Table of Contents (19) Chapters

Preface
1. Unreal Engine Introduction 2. Working with Unreal Engine 3. Character Class Components and Blueprint Setup 4. Player Input 5. Line Traces 6. Collision Objects 7. UE4 Utilities 8. User Interfaces 9. Audio-Visual Elements 10. Creating a SuperSideScroller Game 11. Blend Spaces 1D, Key Bindings, and State Machines 12. Animation Blending and Montages 13. Enemy Artificial Intelligence 14. Spawning the Player Projectile 15. Collectibles, Power-Ups, and Pickups 16. Multiplayer Basics 17. Remote Procedure Calls 18. Gameplay Framework Classes in Multiplayer

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 2020 Publisher: Packt ISBN-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.
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 €14.99/month. Cancel anytime}