In this post we’re going to see how to create a game module for Unreal Engine 4. Imagine that modules are containers for a collection of related classes. After you’re done with this tutorial you can read more about the pros and cons of multiple module creation in Unreal Engine 4 in the official documentation.

This post was written in 4.15 version of the engine. Depending on the time you’re reading this, this information may be outdated.

In order to create a module we have to do the following things:

  1. Modify the .uproject file of your project to include the new module
  2. Create a Module Build file that includes other dependencies and contains a path for private and public include paths
  3. Create at least one class inside our Module

Before you move any further, make sure to close the project you’re currently editing. So, let’s get started!

Modifying the .uproject file

To modify the .uproject file right click on it and open it up using a text editor of your choice.

By default, your file will contain at least one module that has the same name as your UE4 project. After the ending bracket on the modules add a comma and then add your module. In my case, I added a runtime module named OrfeasModule. Here is the complete .uproject file:

Save your file and let’s create the Module Build File.

Creating a Module Build File

Navigate inside your project’s Source folder and create a new folder with the same name as your plugin (in my case, this will be OrfeasModule). Then, inside that folder add:

  • A folder named Public (this will contain the header files of the classes you’re going to add)
  • A folder named Private (this will contain the source files of the classes you’re going to add)
  • A new .cs file that has the following name [YourModuleName].Build.cs (in my case, this will be OrfeasModule.Build.cs)

Here is a screenshot of my folder structure so far:

Open up the .cs file and add the following code:

Depending on your needs, you may need to add more dependencies to your module later on.

Creating a module class

The last thing we need to do is to add a new class that will handle the startup and shutdown of our module. Open up a text editor of your choice (again) and add the following code:

This is the header file of our class. Save it inside the Public folder we’ve added before with the same name as your module (in my case this is the OrfeasModule.h).

Then, create the following file using your text editor and save it inside the Private folder we’ve added before:

Then, go to your .uproject file again and select the generate project files. Once you open up your editor, your module will be loaded. If you attempt to add a new c++ class using the class wizard, you can choose to store your class in your newly created module:


Share postShare on Facebook8Tweet about this on TwitterShare on LinkedIn0Share on Reddit9