Build the project

Starting from an ordinary Unreal Engine Third Person project: convert it to C++, add a server target, and point the server at a map.

Start from

A project made from the Third Person Template, packaged and working — see prepare your app. If you stream that as it stands, two viewers get two separate worlds and cannot see each other. That is what the rest of this fixes.

Open it in a source build of Unreal — the E3DS engine build or Epic's source from GitHub. The Launcher engine cannot build the server target in step 3.

Step 1. Convert the project to C++

Why this is necessary

A server build is declared by a .Target.cs file, which lives in the project's Source folder. A Blueprint-only project has no Source folder, and adding a C++ class is what creates one. That is the entire reason for this step — you do not have to write any C++.

  1. Tools → New C++ Class, choose Actor, and create it. Then close the editor.

    Choosing Actor when adding a new C++ class
  2. Right-click the .uproject and choose Generate Visual Studio project files.

    Generating Visual Studio project files
  3. Open the .sln, select your project under Games, set the configuration to Development Editor, and build with Ctrl+B.

    Building as Development Editor in Visual Studio

Step 2. Add the server module

In the project's Source folder, create a file named YourProjectNameServer.Target.cs — with your real project name — and put this in it:

// Fill out your copyright notice in the Description page of Project Settings.

using UnrealBuildTool;
using System.Collections.Generic;

public class YourProjectNameServerTarget : TargetRules
{
	public YourProjectNameServerTarget(TargetInfo Target) : base(Target)
	{
		Type = TargetType.Server;
		DefaultBuildSettings = BuildSettingsVersion.V2;   // copy from YourProjectName.Target.cs

		ExtraModuleNames.AddRange( new string[] { "YourProjectName" } );
	}
}

Step 3. Build both targets

  1. Regenerate the Visual Studio project files, so the new target is picked up.

  2. Open the .sln, set the configuration to Development Server, and build with Ctrl+B.

    Building the Development Server configuration
  3. Switch to Development Editor, build again, then press F5 — which opens the project in Unreal.

    Building the Development Editor configuration
You should now see a Development Server configuration

If it is not in the list, either the .Target.cs file was not picked up — check the filename and regenerate the project files again — or the project is open in the Launcher engine, which cannot build a server target at all. Fix whichever applies before going further.

Step 4. Tell the server which map to open

In Project Settings → Maps & Modes — both settings are hidden until you expand Advanced, under Default Modes and under Default Maps:

SettingValue
Global Default Server Game ModeThe same game mode as your Default Game Mode
Server Default MapThirdPersonMap — or VRTemplateMap for a VR project
Configuring Maps and Modes for the server

Last updated