Unreal Setup

Introduction

This tutorial guides you through the process of setting up your Unreal game and integrating the GameSparks plugin and explains:

Marketplace Plugin? If you are using the Marketplace plugin, then go straight to GameSparks Object and GameSparks Component.

SDK Download and Setup

You'll require the following to compile and run the Unreal Engine SDK provided by GameSparks:

Once you've downloaded the required tools and installed them successfully, you're ready to start developing.

Creating a New Mixed Project

To create a new Mixed Project:

l

You have now successfully created a Mixed Project and you can skip the Blueprint Only Project tab and move on to the Mixed Project tutorial.

Blueprint Only Project

If your game is a Blueprint only project with no C++ files, you'll need to modify it to make it into a mixed project. This will ensure you have the right components to compile the GameSparks SDK and build your game without any issues.

To do this:

  1. Create a new C++ Class in your project.
  2. Click File>New C++ Class... in your Unreal Engine. At this point, you'll be prompted to select a Parent Class.
  3. Select "None", then click Next.
  4. Name your class and mark it as private (This is a C++ specific differentiation which won’t matter to us at this point).
  5. Hit Create Class to initiate the generation of C++ files for your game.

l

Your game is now a mixed project and is ready to receive the GameSparks SDK files. This is covered in the next section.

Mixed Project

To enable the GameSparks SDK in your Unreal Engine Project, you'll have to grab the "plugin" folder from the SDK you've downloaded and move it to your Project folder. Be sure to rename this folder as "Plugins". If you don't, the folder will not be recognized by the Unreal Engine Compiler:

l

In your project's build file - located under Source> ProjectFolder folder - add "GameSparks" to the PublicDependencyModuleNames array:


PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "GameSparks", "OnlineSubsystem" });

Compiling Project

To compile your project:

Common issues revolve around cached data or the plugin not being recognized. If you have issues:

GameSparks Object and GameSparks Component

The GameSparks Module instance allows you to connect to your backend through your API Key and Secret. The two ways to interact with the Module is through the GameSparks Object and the GameSparks Component. Both are proxies to the module so you can use both at the same time or you can use either the GameSparks Object or the GameSparks Component separately.

Multiplayer Games! We recommend you use the GameSparks Object if you're working with a multiplayer game that uses Client-Server relationship where the Client needs to have and interact with their own module.

GameSparks Object

Create your own custom Game Instance.

l

Set your Game Instance as your default by going to Edit -> Project Settings -> Maps and Modes -> Game Instance.

In your Game Instance, create a GameSparks Object and a message handler object and promote them to variables.

l

You can interact with the GameSparks Object and the message handler anywhere in your BP Classes. For multiplayer games we recommend playerController class.

To connect:

l

To listen for messages, for example script messages:

l

GameSparks Component

Create your own custom Blueprint Game Mode:

l

Once the new Game Mode has been created, make a new GameSparks Component for it:

l

Now, you'll need to drag-and-drop the component into the Event Graph pane in the Unreal Engine. This allows you to call the GameSparks Functions within the Editor:

l

For this tutorial we'll be using the pre-built Begin Play Event to connect to the GameSparks Service:

l

Note: The Connect function will require your GameSparks API Key and Secret to work. If you've forgotten these, refer to the Game Set Up guide, which can be found here.

At this point, you'll want to receive feedback from the module to ensure that you have actually connected. To do this, you need an OnGameSparksAvailableDelegate Event from the GameSparks component. By clicking on the GameSparks Component you'll see the Event has linked to it and can be clicked and dropped into the Event Graph.

When you've added the OnGameSparksAvailableDelegate Event, you'll get an extremely useful tool to check whether your GameSparks connection is valid. You can use the Event Graph to output some information about the connection to GameSparks:

l

The above Event Graph will try to connect to the GameSparks Service and print out a string whether the connection is valid or not.

Now, simply click Play and you should be connected to GameSparks successfully:

l

Did this page help you? Please enter your feedback below. For questions about using this part of the platform, please contact support here