INTRODUCTION TO GAME DEVELOPMENT WITH UNREAL 4 AND C++ – PART 2

This section will explain what a project in Unreal is about, and some of the terminology used in the Unreal Engine Documentation, such as objects, classes, actors and pawns.

Projects

So, what exactly does a UE4 project consist of and what is going on when you create one?

A project consists of everything you want to include in your game, all content and all code for interacting with the objects in this content and can be seen as a self-containing entity from which your game is created.

When you create a project you include the source code for the engine in the project and basically you’re working on a separate version of the engine for every game you create.

This is why the start-up of a new UE4 project is taking so long, as the source code must be compiled before you can use the engine in your game. The next time you open your project, things will start a lot faster.

From the Project Page in the Unreal Editor, you can define the basic properties for your project, such as whether you want to start off with a Blueprint or a C++ based solution.

As mentioned earlier, this choice does only concern how the initial gameplay is defined within your project and can be changed around later.

Also, the Project Page defines what Build Target you’re developing for, as in Desktop / Console, Mobile or any other target you plan on developing for.

This is also a setting that can be changed later, in the Project Properties page in the editor after creation.

You can chose between Scale-able 2D / 3D and Maximum Quality graphics. This setting is also configurable after initial creation and is mostly relevant if you create for mobile platforms.

The project I’ll be creating in this series is called “TheMadMan”, and will be a basic UE4 C++ project that contains no starter content.

blog_unreal_cpp_00

The assets used in the project can be downloaded from GitHub along with the source code and project files if you care to follow along.

I’ll cover setting up a GitHub repository for your own projects in a separate post, where I’ll also give you the address for my project files used in this series.

The different templates you can choose from are examples of different gameplay modes and will be discussed later. For now I’ll go with “Basic Code”.

When I hit “Create Project”, the UE4 Editor starts working with setting up the source code for my project and Visual Studio launches to work through the code produced by the editor.

The editor will detect changes to the code made in Visual Studio and reload any changes back into the editor, and changes initiated in the UE4 Editor will update in Visual Studio.

The default “map” or “level” or “scene” is created in the UE4 Editor. The terminology I’ll use for this is a “level” as this is what it is often referred to in the UE4 Documentation and I personally feel that it gives more meaning than “map”.

The level that starts up with your project is by default called “Untitled”, and you can see this in the lower right of the viewport and on the tab in the upper left corner of the screen.

You can save the level with a different name by choosing File → Save As, or using Ctrl+Shift+S and giving it a new name.

When the Unreal Editor starts your project it will look in the Project Settings to determine what level (map) that loads as default into the editor.

Even if you save your map with a new name, it will load the Untitled map when you start your project if you don’t specify otherwise in the Edit → Project Settings → Maps & Modes → Default Maps → Editor Startup Map.

You can see your newly saved level (map) in the Content Browser, which is a central component of the UE4 Editor.

ue4_new_project

A project is stored with a .uproject extension

Although a project is often referenced by the .uproject file associated with it, they are actually two separate files that exist alongside each other. The .uproject is a reference file used to create, open, or save a file, whereas the Project contains all of the files and folders associated with it.

You can create any number of different Projects which can all be maintained and developed in parallel. Both the Engine (and Editor) can easily switch between them, which will allow you to work on multiple games at once or have several test projects in addition to your main game Project open at any time.

Objects

The basic building blocks of the Unreal Engine are Objects of various kinds. The base that most elements in the engine gets functionality from or more correctly “inherits” from is the Object class, UObject.

From C++, UObject is the base class of all other Unreal Engine Objects and contains essential functionality for other objects you create, such as garbage collection and property support (through UProperty).

Actors

An actor is any object that you can add to your map (aka level). You could say that anything that can be “acted on” is an Actor. Actors support basic properties such as transformation (movement), rotation and scale in 3D space and actors can be made to spawn (get created) and destroyed by your gameplay code.

In C++ AActor is the base class for all actors. Actors can be static meshes, cameras, lights, particle emitters or skeletal meshes to name a few.

Actors will include “Components” that define their behavior and what they can do, like a light actor will include a component that defines what type of light it is, like a spot light will have a spot light component that defines how light is emitted and so on.

The actor will have access to and can use the functionality provided by the component.

Classes

Classes define the properties (state) and behavior of actors and objects in your game.
Classes in C++ defines a hierarchy where a given class can inherit from their parent classes and also pass information down to new child classes (sub class) that inherits from it.

I’ll have much more to say about classes when I start writing some actual code.
One thing worth mentioning is that you can also use Blueprints to define Unreal classes using the editor.

Pawns

A Pawn is a sub-class of Actor that can act as a character in your level and can be controlled by a human player or as an NPC (Non Player Character) controlled by the game’s AI. (Artificial Intelligence).

A player controlled by a human player is said to be “possessed” and an NPC is said to be “unpossessed”.

Characters

A Character is a sub-class of a Pawn that’s intended to be used as a player character.

It includes collision properties (how it reacts to other objects in the environment) and input bindings for bipedal (two legs) movement among other things that can be controlled by the player.

PlayerControllers

The PlayerController Class is used to take player input and translate that into interactions in the game and every game has at least one PlayerController in it. A PlayerController often possesses a Pawn or Character as a representation of the player in a game.

There are also many other terms that I’ll cover as the need shows up, but this is the fundemental terminology you’ll need to understand to follow tutorials on beginning game development in Unreal Engine 4.

What’s up next?

The next post will cover some more details on how to write C++ code in the “Unreal Style”, so that your code will blend easier with the existing code and the code that gets created by the Unreal Editor.

Unreal has their own coding standard that is slightly different from most mainstream coding standards used in C++ programming, so it deserves some attention.

Introduction to Game Development with Unreal 4 and C++ – Part 1

Welcome to the first post in the series I’ve called “Introduction to Game Development in Unreal 4”.

The posts will not be very long in the beginning, just bite-sized chunks of newly acquired wisdom.

You can start a new instance of the Unreal Engine through the Epic Launcher that gets installed when downloading UE from www.unrealengine.com.

First, off course you have to download and install the engine itself. This should be self-explanatory.

So, when you first fire up the Unreal 4 Engine, you’re presented with various options for creating a project from different templates. You can choose a “Blueprint” project or a C++ project, and you can enable or disable the option of including the “Starter Content”.

The choice of project type is not too important, as you’re free to create “Blueprints” in a C++ projects and vice versa. Content can also be imported into your project after its initial creation, so don’t worry too much about choosing the “correct” option early on.

First off, let’s spend some time (this first post) on describing a little bit about the difference between a Blueprint and a C++ project. What is a Blueprint?

The answer to this will depend on who you ask, and how competent this person is with Unreal Engine.

First of all, Blueprints are not necessarily a “beginners” way of creating a game in UE.

Basically one can say that Blueprints is a way to visually develop game logic using nodes and to configure the connections between these nodes with wires.

That’s not an overly technical definition, but I think you get the point.

blue_0

While it is easier to understand Blueprints initially, and most newcomers will indeed prefer to create their games this way, I’d say that if you try to create a fairly complex game using only Blueprints, you’re in for some serious headache. It WILL get complex and unwieldy pretty fast.

Rather, the way I see the most potential in Blueprints is in the prototyping stage of a level and for trying out different options in a game to present to a client or a friend, then, when you’ve settled on a prototype, you’ll start coding it in C++. This is a much more viable path to follow when creating a computer game.

It will be far easier to edit a class in an editor, than to drag wires along a path of hundreds or thousands of nodes in a Blueprint.

Here’s an example starting to get slightly out of control:

blue

This certainly doesn’t look like my idea of something simple to work with.

But for basic prototyping, Blueprints are a great tool to enhance productivity and development speed, especially in the early phases.

Blueprints can certainly be used for many purposes, but in essence it works best as a tool to extend a core C++ system. As mentioned, C++ can be used to call into a Blueprint and a Blueprint can call C++ code, so the synergy of the two is most often the ideal.

It exists similar tools as add-on’s to the Unity Engine as well, all though probably not as streamlined as the integrated Blueprints in Unreal.

Blueprints should be one of the areas you plan on learning when using Unreal 4, because many people are using them and it is important to be able to understand the concepts if you want to be able to transfer the logic behind a Blueprint graph into C++ code and to be able to send messages between the two.

Whether you choose to focus on learning Blueprints first or the C++ API’s first is a matter of preference.
You don’t have to know Blueprints to program a game in Unreal with C++.

I don’t think I’ll talk very much about Blueprints in this series, but instead focus on the basic interaction between the engine and the development environment, which in my case is Visual Studio 2015 at the time of this writing.

You can certainly use Unreal 4 on both Linux and Mac OSX as well and I’ve tried both.

In both cases you can choose to use the Qt Creator IDE, which is also available to use on Windows.

Qt Creator is a multi-platform, very nice IDE that’s a good alternative to Visual Studio, and can be used to create a wealth of different types of applications including GUI applications that runs on all supported platforms unchanged.

For some tips on using Qt Creator on Windows:

https://wiki.unrealengine.com/Using_QtCreator_With_UnrealEngine4

For more information on setting up the engine to work with Qt Creator on Mac OSX and Linux, refer to the Unreal Documentation and do some Google searching!

If you’re just starting out and have access to a computer running Windows, you’d probably want to use this setup, as it is the most widely tested configuration to run Unreal Engine 4 in and generally will give you the least problems early on.

This is a moving target though, and many people have started using Unreal 4 on both Linux and Mac machines, so expect this to be a truth with room for modification.

To keep this as simple as possible, I’ll use only Windows and Unreal 4 in this series, but may create some posts using Linux as well, because this is my favorite operating system in many ways.

I guess that’s all for this time!

I’ll be back.