2 - Connecting to SpacetimeDB
Need help with the tutorial? Join our Discord server!
This progressive tutorial is continued from part 1.
Project Structure
Now that we have our client project setup we can configure the module directory. Regardless of what language you choose, your module will always go into a spacetimedb directory within your client directory like this:
blackholio/ # Unreal project root
├── Binaries/
├── blackholio.sln
├── blackholio.uproject
├── Config/
├── Content/
├── Plugins/
│ └── SpacetimeDbSdk/ # This is where the SpacetimeDB Unreal SDK lives
├── ... rest of Unreal files
└── spacetimedb/ # This is where the server module lives
Create a Server Module
Ensure you have SpacetimeDB version >=1.4.0 installed to enable Unreal Engine code generation support. You can use spacetime --version to check your version and you can use spacetime version upgrade to install the latest version.
If you have not already installed the spacetime CLI, check out our Getting Started guide for instructions on how to install.
In the same directory that contains your blackholio project, run the following command to initialize the SpacetimeDB server module project with your desired language:
The blackholio directory specified here is the same blackholio directory you created during part 1.
- C#
- Rust
- C++
Run the following command to initialize the SpacetimeDB server module project with C# as the language:
spacetime init --lang csharp --server-only --project-path . blackholioThis command creates a new folder named spacetimedb inside of your Unreal project blackholio directory and sets up the SpacetimeDB server project with C# as the programming language.
Run the following command to initialize the SpacetimeDB server module project with Rust as the language:
spacetime init --lang rust --server-only --project-path . blackholioThis command creates a new folder named spacetimedb inside of your Unreal project blackholio directory and sets up the SpacetimeDB server project with Rust as the programming language.
Run the following command to initialize the SpacetimeDB server module project with C++ as the language:
spacetime init --lang cpp --server-only --project-path . blackholioThis command creates a new folder named spacetimedb inside of your Unreal project blackholio directory and sets up the SpacetimeDB server project with Rust as the programming language.