UE4 Server Browser (BP)

After following Unreal Engine’s multiplayer shootout demo, I have added a server browser to my original UE4 online shooter.  In this post, I’ll be going over my blueprint implementation of the browser.  In my next, I’ll go over my C++ version.

Setup:

First off, some things need to be tweaked to DefaultEngine.ini in the Config folder.  The online subsystem and default platform service need to be configured.  This is where the project would be configured to work with something like Steam’s API, but for LAN’s sake, just add the following to the file:

[OnlineSubsystem]
DefaultPlatformService=Null

If the project was made as a C++ project, then ProjectName.build.cs file needs to look like this:

Hosting a game:

Hosting on blueprints is pretty straightforward.  Simply use the Create Session node and switch to the level on successful connection.

Searching for a game:

First, display the browser widget, which will start its own script:

In the browser widget, clear any old entries.

Call the Find Sessions node, and check if that either fails or returns 0 servers.

If it fails, just return, or display an error message, but if not, create clickable widgets that represent individual rows in the browser.  These widgets should contain the session result structure that they represent.

 

Joining a session:

When those widgets are clicked, just call the blueprint below using the session result structure associated with the widget:

And that’s it!  The scene should sync to the session if the host was set up correctly.

 

Destroying a session:

Leaving and destroying the session is as simple as calling the Destroy Session node.  It’s pretty straightforward.

One Comment Add yours

Leave a comment