Search documentation

Find pages, sections, and content across all docs.

WavedashDocs

Unreal Engine

Package your game with Unreal Engine 5.9's web target and upload it.

Unreal Engine 5.9 adds a web target, Wasm (WebAssembly + WebGPU). Package your project for it, add a small script that tells Wavedash when the game is ready, and upload the staged folder.

View Lyra on GitHub Playtest the example project

The web target is experimental in UE 5.9 Preview 1, so expect changes before 5.9.0. See Epic's 5.9 Preview announcement (with known issues) and release notes.

Requirements

  • A source build of UE 5.9 Preview 1 or later (5.9.0-preview-1). Epic says the web target currently needs a source build.

  • A C++ project. Blueprint-only projects need one C++ class first (Tools > New C++ Class). The C++ Third Person template is a good start.

  • emscripten 6.0.10, exactly. Point WASM_EMSDK_ROOT at it, then restart the editor:

    git clone https://github.com/emscripten-core/emsdk.git ~/emsdk-6.0.10
    cd ~/emsdk-6.0.10 && ./emsdk install 6.0.10 && ./emsdk activate 6.0.10
    export WASM_EMSDK_ROOT=~/emsdk-6.0.10
  • A browser with WebGPU: Chrome, Edge, or Safari on macOS.

Add the Wavedash bridge

Save this as <Project>/Build/Wasm/Template/wavedash.js. It forwards Unreal's loading progress to Wavedash and calls Wavedash.init() when the game is ready, or when the page shows an error.

(() => {
  const sdk = () => window.Wavedash;
  if (!sdk()) return; // served outside Wavedash

  let initialized = false;
  const init = () => {
    if (initialized) return;
    initialized = true;
    sdk().updateLoadProgressZeroToOne(1);
    sdk().init({ debug: false });
  };

  // The page writes its progress bar's value (0-100) to aria-valuenow.
  const bar = document.getElementById("progressbar");
  let last = -1;
  const report = () => {
    const value = Number(bar && bar.getAttribute("aria-valuenow"));
    if (initialized || !Number.isFinite(value) || value <= last) return;
    last = value;
    sdk().updateLoadProgressZeroToOne(Math.min(1, value / 100));
  };
  if (bar) {
    new MutationObserver(report).observe(bar, { attributes: true, attributeFilter: ["aria-valuenow"] });
    report();
  }

  // body[data-cover] follows the loading cover; init once it lifts or stops on an error.
  const watch = () => {
    if (["lifted", "click", "failed", "ended"].includes(document.body.dataset.cover)) init();
  };
  new MutationObserver(watch).observe(document.body, { attributes: true, attributeFilter: ["data-cover"] });
  watch();
})();

Load it from Config/DefaultEngine.ini:

[/Script/WasmTargetPlatform.WasmTargetSettings]
IntroShellScript=wavedash.js

Package

Engine/Build/BatchFiles/RunUAT.sh BuildCookRun -project=<Path>/<Project>.uproject -platform=Wasm \
  -clientconfig=Shipping -build -cook -stage -pak -iostore -package \
  -archive -archivedirectory=<Path>/build -AdditionalPackageOptions=-WasmNoBrotli \
  -unattended -utf8output
  • Upload Shipping builds. Development builds embed source paths.
  • -WasmNoBrotli skips .br copies. Wavedash's CDN compresses files itself.
  • Upload build/Wasm. Never upload build/Wasm-Debug: it holds the symbol map.

wavedash.toml

game_id = "YOUR_GAME_ID_HERE"
upload_dir = "./build/Wasm"
entrypoint = "index.html"

Calling the SDK from C++

Unreal runs game code in a Web Worker, but window.Wavedash lives on the browser's main thread. Call the SDK there with MAIN_THREAD_ASYNC_EM_ASM, which doesn't block the game:

#if PLATFORM_WASM
#include <emscripten/em_asm.h>
#endif

void UnlockAchievement()
{
#if PLATFORM_WASM
	MAIN_THREAD_ASYNC_EM_ASM({
		const sdk = window["Wavedash"];
		if (sdk) sdk["setAchievement"]("first_win");
	});
#endif
}

Write SDK names in brackets so a minifier can't rename them. To get a value back, have the main thread write it into memory the game owns, then read it on the game thread. Avoid the blocking MAIN_THREAD_EM_ASM_INT variants.

Multiplayer

Unreal's own networking can run browser to browser over Wavedash P2P, as in the example project above: a player hosts a listen server and friends join from an invite link. It takes a socket subsystem that hands Unreal's packets to the page, a page script that sends them with sendP2PMessage and opens and joins lobbies, and listen servers turned back on in Config/Wasm/WasmEngine.ini:

[ConsoleVariables]
net.SupportsListenServers=1

Lyra is Epic's Lyra Starter Game. Its source is in the Unreal Engine repository, which needs a GitHub account linked to Epic.

Limitations

  • Rendering: the mobile renderer only. No Nanite, Lumen, virtual shadow maps, or hardware ray tracing.
  • Memory: a 4 GB heap.
  • Networking: engine HTTP is off. Call web services from JavaScript.
  • Loading: Wavedash's progress bar holds near the start while the game's code downloads.
  • Audio starts after the player's first click or key press.