> ## Documentation Index
> Fetch the complete documentation index at: https://docs.opengame.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Unreal Engine

> Package an Unreal Engine 5.9 project for the web with the Wasm platform, deploy the Wasm folder to OpenGame, and call the SDK from C++.

OpenGame hosts the Wasm folder that Unreal Engine 5.9 packages for the web: `index.html`, the `wasm-*.js` page scripts, the game's `.js` and `.wasm` under `<Project>/Binaries/Wasm`, the `.pak`, `.utoc` and `.ucas` containers, and the Brotli copies Unreal writes next to them. The game runs in WebAssembly with threads and renders with WebGPU.

| Topic | On OpenGame |
| - | - |
| Hosting | An Unreal Engine 5.9 Wasm package, Shipping configuration |
| Services | Player, leaderboards, achievements and events, through the page's `window.OpenGame` from C++ |
| Threads | Always on in a Wasm package. OpenGame serves it cross-origin isolated |
| Renderer | WebGPU only. There is no WebGL fallback |
| Multiplayer | Datagrams over a WebSocket relay you run, to your own server. Untested on OpenGame. See [Multiplayer](https://docs.opengame.io/guides/multiplayer.md#unreal-engine) |

The Wasm platform is new in Unreal Engine 5.9 and Epic calls it experimental. Epic's notes in your engine, `Engine/Platforms/Wasm/Docs/GettingStarted.md`, list what the platform needs: a C++ project, the Emscripten version the engine requires, and on a Mac or Linux an engine built from source. Epic's licence terms, royalties included, apply to a game you publish here as they do on any other site.

## Package the game

1. Set up Emscripten as `GettingStarted.md` says, and check it under **Platforms > Wasm** in the editor.
2. In **Project Settings > Packaging**, set **Build Configuration** to **Shipping**.
3. Choose **Platforms > Wasm > Package Project**, and pick a `Build` folder in your project as the output. Unreal writes the package into `Build/Wasm`.
4. Deploy `Build/Wasm` as Unreal wrote it, with all the `.br` copies. Don't replace a single file: the package's manifests list each file's size and hash.

**Inject isolation headers** in **Project Settings > Platforms > Wasm** is for hosts that cannot send headers. OpenGame sends them, so leave it on or off.

## Deploy

From the project folder, where the `.uproject` is:

```bash theme={"system"}
opengame init .
opengame check .
opengame deploy .
```

`init` detects Unreal from the `.uproject`, sets `build.output` to `Build/Wasm`, and adds `"requires": { "renderer": "webgpu" }` to `opengame.json`, so a player with no WebGPU in the browser gets a message before the game loads. Package again before each deploy, because the CLI does not run Unreal. Run from inside `Build/Wasm` instead and `init` names the engine from the package. [Export and deploy](https://docs.opengame.io/engines/workflow.md) covers each step and `opengame submit`.

## What the package needs from the browser

* **WebGPU.** Chrome and Edge 133 or later, Firefox 141 or later on Windows, and Safari on iOS 26 or macOS 26. Unreal's page shows a message in a browser without it.
* **Threads.** A Wasm package always uses threads. The scan finds them and serves the release cross-origin isolated, so you change nothing. A private preview of a threaded game plays only in Chrome or Edge 137 or later, which isolate the game's frame by themselves. Firefox and Safari need the page around the frame isolated too, which OpenGame does on the published game page. [Threads and WebGPU](https://docs.opengame.io/engines/threads.md) shows how to check the frame.
* **Unreal's service worker runs.** Unreal's `sw.js` keeps the game's files in the browser, so the engine reads the level from there on a return visit instead of over the network. Keep it in the package. OpenGame removes it when the game is taken down or a new version is published, and the page itself always loads from OpenGame. [Service workers](https://docs.opengame.io/reference/runtimes.md#service-workers) has the rules.

## Size

An upload can be up to 4 GiB, with any one file up to 1 GiB. A Third Person template packaged in Shipping is about 225 MB unpacked, most of it a 140 MB `.wasm` that downloads as a 26 MB Brotli copy. `opengame check` reports `size-warn` above 50 MiB unpacked, because a player waits for the boot download before the first frame. Unreal loads the `.ucas` containers in pieces as the game needs them, so a level's assets stream in during play. A game over the archive limit can send large files separately: [upload a large game](https://docs.opengame.io/guides/packaging.md#upload-a-large-game) explains how.

`opengame check` reports `boot-download` when the module takes more than 3 s on a 50 Mbps connection. The `.pak` and `.ucas` containers are read by range as the level asks, so they are not counted. Package in Shipping, and keep the startup map small: the engine loads it before the first frame.

## Connect the SDK

OpenGame adds the SDK to threaded builds, so a Wasm package's page has `window.OpenGame` without any change. Call it from C++ with Emscripten's `MAIN_THREAD_EM_ASM`, which runs the JavaScript on the page's thread, from any Unreal thread, and waits until it has run:

```cpp OpenGameCalls.h theme={"system"}
#pragma once
#ifdef __EMSCRIPTEN__
#include <emscripten/em_asm.h>

// The first playable frame is on screen.
inline void OpenGameReady()
{
    MAIN_THREAD_EM_ASM({
        if (window.OpenGame) OpenGame.init().then(function () { OpenGame.ready(); });
    });
}

// Submit a score to a leaderboard named in opengame.json.
inline void OpenGameSubmitScore(const char* Board, double Score)
{
    MAIN_THREAD_EM_ASM({
        if (window.OpenGame) OpenGame.leaderboard(UTF8ToString($0)).submit($1);
    }, Board, Score);
}

// Unlock an achievement declared in opengame.json.
inline void OpenGameUnlock(const char* Id)
{
    MAIN_THREAD_EM_ASM({
        if (window.OpenGame) OpenGame.achievements.unlock(UTF8ToString($0));
    }, Id);
}
#else
inline void OpenGameReady() {}
inline void OpenGameSubmitScore(const char*, double) {}
inline void OpenGameUnlock(const char*) {}
#endif
```

Call `OpenGameReady()` once the first level is on screen, for example from your game mode's `BeginPlay`. The call waits for the page to read the string, so a temporary such as `TCHAR_TO_UTF8(*BoardName)` works when you write it inside the argument list. Don't switch a call that passes a string to `MAIN_THREAD_ASYNC_EM_ASM`: that returns at once, and the string can be freed before the page reads it. These calls return nothing to C++. To read results such as the player or a leaderboard's top scores, call the SDK in JavaScript and pass the answer to the game. [Platform services](https://docs.opengame.io/engines/services.md) lists the calls.

## In the player

The player loads your `index.html` in a frame on the game's address. Unreal's page sizes the canvas from the window, so it follows the frame in and out of fullscreen.

* **Mouse look.** Unreal's page takes pointer lock on a click in the canvas when the game wants high-precision mouse input, which the frame allows.
* **Sound.** A browser pauses audio a game opens before the first press. The player starts it when the person presses Play, or presses a key or the screen in the game.
* **Keyboard and gamepads.** The game gets keys once it has focus. The player focuses it when it opens, and a click in the game focuses it again.

## Common findings

| Finding | What to do |
| - | - |
| `engine-threads` | The package uses threads. No change needed. |
| `size-warn` | A note above 50 MiB. Package in Shipping and keep the first level's assets small. |
| `outbound-origin` on `www.google.com` | The "Get Chrome" link on Unreal's error card. It is a link, not a request. |
| `engine-modal-dialog` | Emscripten's standard input reader can call `prompt`. Unreal never requests input from it, so no change is needed. |

`opengame check` leaves out `index.html.br`, because OpenGame serves a page uncompressed.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.