Games

Creating a playable demo of the SpatialOS Unreal Integration

We have released our experimental Unreal integration! Find out more and begin developing your SpatialOS game with Unreal.


It has always been our ambition to integrate the popular Unreal Engine with SpatialOS. When announcing plans for Unreal earlier this year, we touched upon the flexibility and popularity of the engine across the whole of the game-developer community as key reasons for this.

Unreal_Engine_Black

With the announcement of SpatialOS going to GDC17 and several developers already working on SpatialOS games in Unreal (check out Chronicles of Elyria and Rebel Horizons), we felt it was important to have a more broadly usable integration available publicly.

At Improbable, we always believe the best software comes from large amounts of early user feedback, and a heavy amount of dogfooding ourselves. To that end, we assembled two special teams of SpatialOS engineers and designers:

  1. An integration team to create an experimental Unreal integration that would demonstrate how SpatialOS concepts gel into the engine, including C++ and Blueprint game code.
  2. A ‘red team’ to rapidly consume this integration on the fly in a game-jam fashion, providing rapid feedback and creating an awesome example game in the process.

Designing the demo game

Starting this game jam project would have been even harder if the team didn’t have any notion of what the finished demo should look and play like. Luckily there always seem to be plenty of interesting and cool art assets and code snippets littering the desks of Improbable’s Games Division. The team were especially drawn to some concepts they found for a sci-fi-inspired, visually-arresting, third-person, multiplayer, survival game.

DUSK_Engineer_01

Taking these concepts as a basis, work began on designing the demo of a game called DUSK. The top-line pitch is exciting for anyone familiar with the films Aliens (1986) and Pitch Black (2000) – in DUSK you should be afraid of the coming of night…

DUSK_Panoramic_02

As a SpatialOS title, DUSK also needs to show some of the functionalities that are made possible by having the power of a persistent gameworld with always-online multiplayer elements taken into account. To this end, it’s planned for the game to have a continuous day-night cycle, physics-driven interactable objects, and an environment inhabited with NPCs that exhibit intelligent behaviour patterns. The team have named these insidious foes Mantids – docile plants during the day but a vicious menace at night when they attack the player-controlled outpost.

DUSK_Base_01

The core gameplay loop is loosely based on the Tower-Defence model. Players scour the landscape for resources as the daylight dwindles (discovery, stockpiling, risk-reward travel) and then launch into third-person, co-operative action at night when the Mantids begin their attack and players must defend their HQ at all costs.

Getting the demo game into Unreal

By starting with a non-SpatialOS game, the teams’ situation reflects the experience that an external developer might have, which is to integrate a kind of Unreal Engine prototype game with SpatialOS. This makes DUSK also an exciting opportunity to also get some valuable insight into the technical processes and design challenges that our SpatialOS users might have to consider and encounter.

The team worked to upgrade some existing code to the most modern iteration of the Unreal Engine available at the time, which was Unreal Engine 4.14.3. This was to ensure that our SpatialOS Unreal integration is demonstrably modern in its design, implementation, and capabilities.

DUSK_Forcefield_01

Integrating with SpatialOS

As the process of integrating the updated demo began, the integration team’s first challenge became clear – running Unreal in the cloud required it to be built in Linux.

The next hurdle was that Unreal typically assumes that you will only be building on the client-side and not on the server-side. This challenged the team with building Unreal Engine from source. Doing so required us to make some subtle modifications to the code- this would be the same for any external team.

This brought about more important questions for how we would set out the best practice for future Unreal integrations. Should the team fork their version of Unreal Engine and tell future users to build that? This would surely lead to people asking the reasonable question – “why am I building a custom version of a custom version?” Instead, the integration team went for full transparency in their process. Future integrations of Unreal and SpatialOS would come with the instruction – follow Epic’s own guide on how to build from source and apply these handy patches we’ve made!

Using Unreal’s Blueprints Visual Scripting

Next, the team worked on a robust and deep integration with the Unreal Engine, using a robust code generation system that enables developers to fully make use of the powerful workflow and tools from the Unreal Engine, which they would likely be familiar with. This includes automatically generating UCLASS and UPROPERTY definitions for using Unreal’s Blueprints Visual Scripting system.

blueprint_interface

This means that users can simply write their schema and automatically be provided with blueprint nodes that are ready for them to use in their project.

Leveraging Unreal Engine’s Blueprints for specifying and defining SpatialOS-related logic and computation is incredibly powerful. In addition to enabling faster iteration times for implementing gameplay features, it has also provided a way to visualize how SpatialOS related concepts such as authority delegation, entity creation, and worker commands in a natural, intuitive way. Here is an example GIF of how it looks:

dusk_smaller

Where is the project now?

The fantastic groundwork the two teams have been putting into this project so far will have ramifications far beyond the making of a playable, if very pretty, tech demo. For everyone involved, it’s all about smoothing the pipeline and creating a technical foundation for this important next step for the opening up of SpatialOS.

It must be said, however, that code best-practice is not the end game for DUSK which is, after all, a game jam-style demo built with time constraints to prove a point. We do plan to publically release the entire source code of DUSK which anyone can download, build and run on their own to see how it all works! Stay tuned for more updates from the team regarding this. For now, we look forward to sharing more information about DUSK and our Unreal integration as it continues to develop, including some gameplay footage and further screenshots.

Thanks for reading!


Check out other developers currently working on Unreal projects with SpatialOS – Soulbound Studios & Entrada Interactive.

Problem? Solution? Idea?

Get involved.

Our SpatialOS community is vibrant and curious, and we always have each other's backs. Come along to the forums to ask questions, find inspiration for your next game, and meet other developers pioneering new worlds.

Build worlds where everything matters

Get SpatialOS Beta now