Back to Spacetimedb

SpacetimeDB Unreal SDK

sdks/unreal/README.md

2.1.02.6 KB
Original Source

SpacetimeDB Unreal SDK

This folder contains the Unreal Engine plugin that allows games to talk to a SpacetimeDB server. The design mirrors the official Rust SDK and borrows ideas from the C# SDK so that projects can share a common workflow across languages.

Overview

The plugin exposes a high level API for establishing connections, invoking reducers and keeping a synchronized cache of database tables. Communication happens over WebSockets using the BSATN binary format. Most of the message and type headers are generated by the SpacetimeDB CLI so that Unreal games can send and receive the same structures as other SDKs.

Feature Highlights

  • Connect to a SpacetimeDB server and authenticate with identity tokens
  • Call reducers and receive their results via Blueprint exposed delegates
  • Subscribe to queries and maintain a local table cache updated by server diffs
  • Serialize common Unreal types to BSATN, including arrays
  • Auto-generated table types keep the API in sync with your database
  • Pure C++ implementation with Blueprint wrappers for easy gameplay scripting

Directory Layout

crates/sdk-unreal/
├── DEVELOP.md           # Notes on integrating the plugin into a project
├── SpacetimeDbSdk/      # The Unreal plugin sources
│   ├── Resources/       # Plugin icons and metadata
│   └── Source/
│       └── SpacetimeDbSdk/
│           ├── Public/  # Headers used by gameplay code
│           │   ├── BSATN/       # BSATN serializer
│           │   ├── Connection/  # Connection and subscription classes
│           │   ├── DBCache/     # Client side table cache utilities
│           │   ├── Tables/      # Base class for generated table wrappers
│           │   ├── Types/       # Generated message and type headers
│           │   └── tests/       # Unit test helpers for BSATN
│           ├── Private/ # Implementation files
│           └── SpacetimeDbSdk.Build.cs

See the README files in each subfolder for more details on the available classes and helpers.

Getting Started

  1. Copy SpacetimeDbSdk into your project's Plugins directory or use the AdditionalPluginDirectories option described in DEVELOP.md.
  2. Regenerate the headers under Public/Types by running the SpacetimeDB CLI against your module schema.
  3. Include SpacetimeDbSdk in your game's build files and start a connection using UDbConnectionBuilder.

With the connection established you can call reducers, subscribe to queries and drive gameplay logic using incoming table data.