Unreal Engine 4 is a collection of game development tools capable of producing everything from 2D mobile games to AAA console titles. It is the engine behind titles such as ARK: Survival Evolved, Tekken 7 and Kingdom Hearts III.
Developing in Unreal Engine 4 is very simple for beginners. Using the Blueprints Visual Scripting system, you can create entire games without writing a single line of code! Combined with an easy-to-use interface, you can quickly get a prototype up and running.
This Unreal Engine 4 tutorial is focused on helping beginners get started. Here are the key points that this tutorial will cover:
- Installing the engine
- Importing assets
- Creating materials
- Using Blueprints to create objects with basic functionality
To learn these, you will create a spinning turntable that displays a banana.
Installing Unreal Engine 4
Unreal Engine 4 uses the Epic Games Launcher for installation. Head over to the Unreal Engine website and click the Get Unreal button at the top-right corner.
You will need to create an account before you can download the launcher. After you have created an account, download the launcher for your operating system.
Once you have downloaded and installed the launcher, open it. The following window will appear:
Enter the email and password you used to download the launcher and click Sign In. Once signed in, this window will appear:
At the top-left corner, click Install Engine. The launcher will take you to a screen where you can select which components to install.
The default selections are Starter Content, Templates and Feature Packs and Engine Source. It is a good idea to leave these checked. Here’s why they are useful:
- Starter Content: This is a collection of assets that you can use for free in your projects. It includes content such as models and materials. You can use these as placeholder assets or in your final game.
- Templates and Feature Packs: Templates set up basic functionality relating to your chosen genre. For example, picking the Side Scroller template will create a project with a character, basic movement and a fixed plane camera.
- Engine Source: Unreal is open source, which means anyone can make changes to the engine. If you ever want to add custom buttons to the editor, you can do it by changing the source code.
Scrolling down the list, there are different platforms available. If you don’t plan on developing for a specific platform, feel free to disable it.
Once you have selected your components, click Install. When the installation completes, the engine will appear in your library. Now it’s time to create the project.
Creating a Project
Click one of the Launch buttons to open the Project Browser. Once it opens, click the New Project tab.
Click the Blueprint tab. Here, you can use one of the templates. However, since you are starting from scratch, select the Blank template.
Further below, you will find additional settings.
Here’s what each option does:
- Target Hardware: Selecting Mobile/Tablet will disable some post processing effects. It will also enable using the mouse as a touch input. Set this to Desktop/Console.
- Graphical Target: Selecting Scalable 3D or 2D will disable some post processing effects. Set this to Maximum Quality.
- Starter Content: You can enable this option to include Starter Content. For the sake of simplicity, set this to No Starter Content.
Finally, there is a section to specify the location of your project folder and the name of your project.
You can change the location of your project folder by clicking the three dots at the end of the Folder field.
The project name does not represent the game’s title so don’t worry if you want to change the title later on. Select the text in the Name field and type in BananaTurntable.
Finally, click Create Project.
Navigating the Interface
Once you have created the project, the editor will open. The editor is split into multiple panels:
- Content Browser: This panel displays all your project files. Use this to create folders and organize your files. You can search for your files by using the search bar or by using filters.
- Modes: This panel lets you select between tools such as the Landscape Tool and the Foliage Tool. The Place Tool is the default tool. It allows you to place many different types of objects into your level such as lights and cameras.
- World Outliner: Displays all the objects in the current level. You can organize the list by putting related items into folders. Also has the ability to search and filter by type.
- Details: Any object you select will have its properties displayed here. Use this panel to edit the settings of the object. Changes made will only affect that instance of the object. For example, if you have two spheres and change the size of one, you will only affect the selected object.
- Toolbar: Contains a variety of different functions. The one you will use the most is Play.
- Viewport: This is the view of your level. You can look around by holding right-click and moving your mouse. To move, hold right-click and use the WASD keys.
What’s the point in having a turntable with nothing to display? Download this model of a banana. Inside are two files: Banana_Model.fbx and Banana_Texture.jpg. Alternatively, you could use your own model but why would you when you have this badass banana?
Before Unreal can use any files, you need to import them. Navigate to the Content Browser and click Import.
Using the file browser, locate the folder where Banana_Model.fbx and Banana_Texture.jpg are. Drag-select both of the files and click Open.
Unreal will give you some import options for the .fbx file. Make sure Import Materials is unchecked as you will be creating your own material. You can leave the other settings alone.
Click Import. The two files will now appear in your Content Browser.
When you import a file, it is not actually saved into your project until you explicitly do so. You can save files by right-clicking the file and selecting Save. You can also save all files at once by selecting File\Save All. Make sure you save often!
Note that in Unreal, models are called meshes. So now that you have a mesh for your banana, it’s time to place it into the level.
Adding Meshes Into the Level
The level is looking pretty empty at the moment so let’s spice it up.
To add a mesh into the level, left-click and drag the Banana_Model from the Content Browser into the Viewport. Releasing left-click will place the mesh.
Objects in a level can be moved, rotated and scaled. The keyboard shortcuts for these are W, E and R. You can then use the manipulator like so:
If you look closely at the banana, you will see that it’s not yellow at all! In fact, it almost looks gray.
To give the banana some color and detail, you need to create a material.
What is a Material?
A material determines how the surface of something looks. At a basic level, a material defines four things:
- Base Color: The color or texture of a surface. Used to add detail and color variations.
- Metallic: How “metal-like” a surface is. Generally, a pure metal will have the maximum Metallic value whereas fabric will have a value of zero.
- Specular: Controls the shininess of non-metallic surfaces. For example, ceramic would have a high Specular value but clay would not.
- Roughness: A surface with maximum roughness will not have any shininess. Used for surfaces such as rock and wood.
Below is an example of three different materials. They have the same color but different attributes. Each material has a high value for their respective attribute. The other attributes are set to zero.
Creating a Material
To create a material, go to your Content Browser and click the green Add New button. A menu will appear with a list of assets you can create. Click Material.
Name the material Banana_Material and then double-click the file to open it in the material editor.
The Material Editor
The material editor is composed of five main panels:
- Graph: This panel will contain all your nodes and the Result node. Pan by holding right-click and moving your mouse. Zoom by scrolling your mouse wheel.
- Details: Any node that you select will have its properties displayed here. If a node isn’t selected, the panel will show the material’s properties instead.
- Viewport: Contains a preview mesh that will display your material. Rotate the camera by holding left-click and moving your mouse. Zoom by scrolling your mouse wheel.
- Palette: A list of all the nodes available to your material.
What is a Node?
Before you start making your material, you need to know about the objects used to make it: nodes.
Nodes make up the majority of a material. Many types of nodes are available and offer different functionality.
Nodes can have inputs and outputs, represented by a circle with an arrow. Inputs will be on the left side and outputs will be on the right side.
Here is an example using a Multiply and Constant3Vector node to add yellow to a texture:
Materials have a special node called the Result node, which has already been created for you in this case as Banana_Material. This is where all your nodes will eventually end. Whatever you plug into this node will determine how the final material looks.
To add color and detail to a model, you need a texture. A texture is just a 2D image. Typically, they are projected onto 3D models to give it color and detail.
To texture the banana, you will use Banana_Texture.jpg. The TextureSample node will allow you to use a texture within your material.
Navigate to the Palette panel and search for TextureSample. Add the node by holding left-click and dragging it into the graph.
To select a texture, make sure you have the TextureSample node selected. Navigate to your Details panel and click the drop-down located to the right of Texture.
The menu that comes up will list all the textures in your project. Select Banana_Texture.
To see the texture on the preview mesh, you need to plug it into the Result node. Hold left-click on the white output pin of the TextureSample node. Drag it to the Base Color input pin of the Result node.
Go back to the Viewport to see the texture on the preview mesh. Rotate it around (by holding the left mouse button and dragging) to see the other details.
Click Apply in the Toolbar to update your material, and close the Materials editor – you are done here.
To use your material with the banana, you need to assign it. Go back to the Content Browser and double-click on Banana_Model to open it. The following editor will appear:
Go to the Details panel and locate the Materials section. Click the drop-down located to the right of Element 0 and select Banana_Material.
Close the mesh editor, go back to the main editor and look at the Viewport. You will see that your banana now has a texture. Congratulations, you now have everything it takes to be a level designer!
Note: If the lighting is too dark, you can change it by going to the World Outliner and clicking on Light Source. In the Details panel, locate the Intensity setting and set it to a higher value.
Even though the banana is looking amazing, it would look even better spinning on a turntable. Creating one is easy using Blueprints.
In its simplest sense, a Blueprint represents a ‘thing’. Blueprints allow you to create custom behaviors for your objects. Your object can be something physical (like the turntable) or something abstract such as a health system.
Want to make a moving car? Make a Blueprint. What about a flying pig? Use Blueprints. How about a kitten that explodes on impact? Blueprints.
Just like materials, Blueprints use a node-based system. This means all you need to do is create nodes and link them; no coding needed!
Note: If you prefer to write code, you can use C++ instead.
While Blueprints are easy to use, they are not as fast as C++ code. So, if you need to use something computationally heavy like a complex algorithm, you should consider using C++.
Even if you prefer using C++, there are times where it is a good idea to use Blueprints. Here are some of the benefits of Blueprints:
- Generally, it is quicker to develop using Blueprints than C++.
- Easy organization. You can separate your nodes into different areas such as functions and graphs.
- If you are working with non-programmers, modifying the Blueprint is easy due to its visual and intuitive nature.
A good approach is to create your objects using Blueprints. When you need extra performance, convert them to C++.
Creating a Blueprint
Go to the Content Browser and click Add New. From the list, select Blueprint Class.
A window will appear prompting you to select a parent class. Your Blueprint will inherit all the variables, functions and components from your chosen parent class. Take a moment to read what each class does.
Note: Since you can place and spawn the Pawn and Character classes, they are also Actors.
Because the turntable is just going to stay in one spot, the Actor class is the most appropriate. Select Actor and name the new file Banana_Blueprint.
Finally, double-click on Banana_Blueprint to open it. Click Open Full Blueprint Editor if a window like this appears:
The Blueprint Editor
First, make sure that you have the Event Graph tab selected in the Blueprint editor.
The Blueprint editor has four main panels:
- Components: Contains a list of the current components.
- My Blueprint: This section is primarily used to manage your graphs, functions and variables.
- Details: This will display the properties of the currently selected item.
- Graph: This is where the magic happens. All your nodes and logic go in here. Pan by holding right-click and moving your mouse. Zoom by scrolling your mouse wheel.
- Viewport: Any components that have a visual element will appear here. You can move and look around using the same controls as the Viewport in the main editor.
Creating the Turntable
To create the turntable, you need two things: a base and a display. You can create both of these by using components.
What is a Component?
If a Blueprint is a car then components are the building blocks that make up the car. The doors, wheels and engine are all examples of components.
However, components are not limited to being physical objects.
For example, to make a car move, you could add a movement component. You could even make a car fly by adding a flying component.
Before you can see any components, you need to switch to the Viewport view. Click the Viewport tab to switch to it. This is what it looks like:
Note: The DefaultSceneRoot component will not show when playing. It will only show in the editor.
The turntable will use two components:
- Cylinder: A simple white cylinder. This will be the base that the banana sits on.
- Static Mesh: This component will display the banana mesh.
To add the base, navigate to the Components panel. Click Add Component and select Cylinder.
It’s a good idea to make the base a bit shorter. Activate the scale manipulator by pressing R and then scale it down (the exact size doesn’t matter, you can tweak it later if you want).
It’s time to add the mesh. Go back to the Components panel and click Add Component. Select Static Mesh from the list.
To display the banana, select the Static Mesh component and then click the Details tab. Click on the drop-down located to the right of Static Mesh and select Banana_Model.
Move the banana if it is not in the correct position. Activate the move manipulator by pressing W and then move it up.
About Blueprint Nodes
It’s time to make the turntable rotate. This is where Blueprint nodes come in..
Unlike their material node cousins, Blueprint nodes have special pins called Execution pins. A pin on the left is an input and a pin on the right is an output. All nodes will have at least one of these.
If a node has an input pin, it must have a connection before it can execute. If a node is not connected, any subsequent nodes will not execute.
Here is an example:
Node A and Node B will execute because their input pins have a connection. Node C and Node D will never execute because Node C’s input pin does not have a connection.
Rotating the Turntable
Before you start, have a look at the Components panel. You will see that Cylinder and Static Mesh are indented but DefaultSceneRoot is not. This is because they are attached to DefaultSceneRoot.
If you move, rotate or scale a root component, the attached components will too. Using this behavior, you can rotate Cylinder and Static Mesh together rather than individually.
Creating a Node
To start scripting, switch back to the Event Graph tab.
Making an object rotate is so simple that you only need to create one node. Right-click an empty space on the graph to bring up a menu of available nodes. Search for AddLocalRotation. Since you need to rotate the base and banana, you can just rotate the root component. Select AddLocalRotation (DefaultSceneRoot).
Note: If the node isn’t listed, uncheck Context Sensitive at the top-right of the menu.
Your graph will now have a new AddLocalRotation node. The Target input will automatically have a connection to the component you selected.
To set the rotation value, go to the Delta Rotation input and change the Z value to 1.0. This will cause the Blueprint to rotate around it’s Z-axis. Higher values will rotate the turntable faster.
To constantly rotate the turntable, you need to call AddLocalRotation every frame. To execute a node every frame, use the Event Tick node. It’s already in your graph. If it’s not, you can create one using the same method as before.
Drag the output pin of the Event Tick node to the input pin of the AddLocalRotation node.
Note: In this implementation, the rotation rate is dependent on the frame rate. This means the turntable will rotate at a slower rate on slower machines and vice versa. That’s fine for this tutorial because I wanted to keep things simple, but I’ll show you how to solve this in a future tutorial.
Finally, go to the Toolbar and click Compile to update your Blueprint, then close the Blueprint editor.
Adding Blueprints Into the Level
Before adding the Blueprint, go back to the Viewport in the main editor and delete the banana model. To do this, select the model and then select Edit\Delete or press your Delete key.
Adding a Blueprint is the same process as adding a mesh. Hold left-click on the file and drag it into the Viewport.
Navigate to the Toolbar and hit Play to see all your hard work in action!
Note: If you didn’t delete the original banana model, you may get a warning stating the lighting needs to be rebuilt. If you delete the model, the error will no longer appear.
Where to Go From Here?
You can download the completed project for this Unreal Engine 4 tutorial here.
You’ve learned a lot throughout this tutorial but that’s just a tiny portion of Unreal. If you want to keep learning more, check out the next post in the series, where I cover more about Unreal Engine blueprints.