Dedicated Server Guide (Windows)

[for UE4.25.3]

Guide on building Unreal Engine and project in the Dedicated server configuration.

In order to build dedicated servers for Windows, you need a source build of Unreal Engine. Check out Building Unreal Engine from Source. It's also not possible to build an engine from scratch with the blueprint-only project. You need to set up C++ project modules and compile your own engine.

Dedicated Server from a brand new project

Open up source unreal engine, select c++ and third-person template, give it a suitable name and save location.

Once the project and visual studio have finished completely loading, close them both down.

Note again wait until the header files have all been parsed in the Visual Studio before closing. it may prompt you to save just click OK.

Setting up the server Target.cs

Open up the previously created project folder from the file explorer inside there will be a folder called Source.

Create a new Target.cs name in format \[ProjectName\]Server.Target.cs

Paste below snipper to your new file. Simply replace "MyGame" with your project codename.

//replace "MyGame" with your project codename.
//means all words of "MyGame"

using UnrealBuildTool;
using System.Collections.Generic;
public class MyGameServerTarget : TargetRules
{
    public MyGameServerTarget (TargetInfo Target) : base(Target)
    {
        Type = TargetType.Server;
        DefaultBuildSettings = BuildSettingsVersion.V2;
        ExtraModuleNames.AddRange(new string[]
            {
                "MyGame"
            });
    }
}

Switch Unreal Engine versions

Right-click the uproject file and when the menu pops up select "Switch Unreal Engine version...".

Select your source build location in the drop-down and click OK. Note: your source should be loaded from github and compiled already !

Building the server

Open up the Visual Studio project solution and allow it to fully load until it says ready.

Select "Development Editor" configuration.Go to the solution explorer, right-click on your project item and click Build.

Once this is done, go back to the menu and select "Development Server" configuration.Call Build one more time.

Once the compilation succeeded, go into your project folder. Open the Binaries/Win64 folder and you should see server binaries files there.

Compile additional programs.

Open the Unreal Engine editor, continue to work on the UE Eidtor, and add the connection server function.Finally, package and release the client.

Launching and joining the dedicated server

1)Copy the server executable

Go to your project folder, then Binaries, Win64, and find the file called "UE4LaunchServer.exe" and right click it and copy it.

Go to your packaged game location. then WindowsNoEditor, then the name of your project, Binaries, Win64, and paste in the UE4LaunchServer.exe.

2)Create the server shortcut and setup log options

Now take the server file and create a shortcut to it. then rename it to match whatever you called your map inside the project. 

Right-click this shortcut and go to "Properties". At the end of the target path simply add -log.

3)Launch and test the server

Double click the server shortcut you just modified.

click the UE4Launch.exe to join the server.

猜你喜欢

转载自blog.csdn.net/A_Pointer/article/details/109473714