Skip to content

Commit b44d4ba

Browse files
JasonAtClockworkgefjonjdetterbfops
authored
Unreal Blackholio Tutorial Documentation (#3253)
# Description of Changes Closes: clockworklabs/SpacetimeDBPrivate#1926 Duplicated and rewrote the Unity Blackholio documentation to work with the Unreal SpacetimeDb SDK. # API and ABI breaking changes N/A # Expected complexity level and risk 1 - Documentation only # Testing - [x] Walk-through the documentation using the new Unreal SpacetimeDb SDK --------- Signed-off-by: Jason Larabie <jason@clockworklabs.io> Co-authored-by: Phoebe Goldman <phoebe@clockworklabs.io> Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com> Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
1 parent 20ef7cf commit b44d4ba

19 files changed

Lines changed: 4037 additions & 1 deletion

docs/docs/nav.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ const nav = {
2222
page('2 - Connecting to SpacetimeDB', 'unity/part-2', 'unity/part-2.md'),
2323
page('3 - Gameplay', 'unity/part-3', 'unity/part-3.md'),
2424
page('4 - Moving and Colliding', 'unity/part-4', 'unity/part-4.md'),
25+
section('Unreal Tutorial - Basic Multiplayer'),
26+
page('Overview', 'unreal', 'unreal/index.md'),
27+
page('1 - Setup', 'unreal/part-1', 'unreal/part-1.md'),
28+
page('2 - Connecting to SpacetimeDB', 'unreal/part-2', 'unreal/part-2.md'),
29+
page('3 - Gameplay', 'unreal/part-3', 'unreal/part-3.md'),
30+
page('4 - Moving and Colliding', 'unreal/part-4', 'unreal/part-4.md'),
2531
section('CLI Reference'),
2632
page('CLI Reference', 'cli-reference', 'cli-reference.md'),
2733
page(
@@ -59,6 +65,7 @@ const nav = {
5965
'sdks/typescript/quickstart.md'
6066
),
6167
page('TypeScript Reference', 'sdks/typescript', 'sdks/typescript/index.md'),
68+
page('Unreal Reference', 'unreal/reference', 'unreal/reference.md'),
6269
section('SQL'),
6370
page('SQL Reference', 'sql', 'sql/index.md'),
6471
section('Subscriptions'),

docs/docs/unity/part-3.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ The `OnApplied` callback will be called after the server synchronizes the initia
610610

611611
In the scene view, select the `GameManager` object. Click on the `Border Material` property and choose `Sprites-Default`.
612612

613-
### Creating GameObjects
613+
### Creating GameObjects
614614

615615
Now that we have our arena all set up, we need to take the row data that SpacetimeDB syncs with our client and use it to create and draw `GameObject`s on the screen.
616616

docs/docs/unreal/Circle.png

5.94 KB
Loading

docs/docs/unreal/index.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Unreal Tutorial - Overview
2+
3+
Need help with the tutorial or CLI commands? [Join our Discord server](https://discord.gg/spacetimedb)!
4+
5+
In this tutorial you'll learn how to build a small-scoped massive multiplayer online action game in Unreal, from scratch, using SpacetimeDB. Although, the game we're going to build is small in scope, it'll scale to hundreds of players and will help you get acquainted with all the features and best practices of SpacetimeDB, while building [a fun little game](https://github.com/ClockworkLabs/Blackholio).
6+
7+
By the end, you should have a basic understanding of what SpacetimeDB offers for developers making multiplayer games.
8+
9+
The game is inspired by [agar.io](https://agar.io), but SpacetimeDB themed with some fun twists. If you're not familiar [agar.io](https://agar.io), it's a web game in which you and hundreds of other players compete to cultivate mass to become the largest cell in the Petri dish.
10+
11+
Our game, called [Blackhol.io](https://github.com/clockworklabs/SpacetimeDB/tree/master/demo/Blackholio), will be similar but space themed. It should give you a great idea of the types of games you can develop easily with SpacetimeDB.
12+
13+
This tutorial assumes that you have a basic understanding of the Unreal Engine, using a command line terminal and programming in C++. We'll give you some CLI commands to execute. If you are using Windows, we recommend using Git Bash or PowerShell. For Mac, we recommend Terminal.
14+
15+
We’ll keep things intentionally simple: a single “Game Manager” class, minimal error handling, and hardcoded settings where convenient. This makes the SDK flow easy to see. For production, prefer Unreal’s Subsystems, move secrets out of code, follow best practices, and add proper logging/retry.
16+
17+
SpacetimeDB supports Unreal Engine version `5.6`. This tutorial has been tested only with that version.
18+
19+
This tutorial is written for C++, but the SpacetimeDB Unreal client SDK also supports Blueprints! Stay tuned for a Blueprint-based tutorial.
20+
21+
Please file an issue [here](https://github.com/clockworklabs/SpacetimeDB/issues) if you encounter an issue with a specific Unreal version, but please be aware that the SpacetimeDB team is unable to offer support for issues related to versions of Unreal prior to `5.6`.
22+
23+
## Blackhol.io Tutorial - Basic Multiplayer
24+
25+
First you'll get started with the core client/server setup. For part 2, you'll be able to choose between [Rust](/docs/modules/rust) or [C#](/docs/modules/c-sharp) for your server module language:
26+
27+
- [Part 1 - Setup](/docs/unreal/part-1)
28+
- [Part 2 - Connecting to SpacetimeDB](/docs/unreal/part-2)
29+
- [Part 3 - Gameplay](/docs/unreal/part-3)
30+
- [Part 4 - Moving and Colliding](/docs/unreal/part-4)
31+
32+
## Blackhol.io Tutorial - Advanced
33+
34+
If you already have a good understanding of the SpacetimeDB client and server, check out our completed tutorial project!
35+
36+
https://github.com/clockworklabs/SpacetimeDB/tree/master/demo/Blackholio
645 KB
Loading
10.6 KB
Loading
5.4 KB
Loading
50.4 KB
Loading

docs/docs/unreal/part-1.md

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# Unreal Tutorial - Part 1 - Setup
2+
3+
Need help with the tutorial? [Join our Discord server](https://discord.gg/spacetimedb)!
4+
5+
> A completed version of the game we'll create in this tutorial is available at:
6+
>
7+
> https://github.com/clockworklabs/SpacetimeDB/tree/master/demo/Blackholio
8+
9+
## Prepare Project Structure
10+
11+
> **NOTE:** Ensure you have SpacetimeDB version 1.4.0 installed to enable Unreal Engine code generation support.
12+
13+
This project is separated into two subdirectories;
14+
15+
1. Server (module) code
16+
2. Client code
17+
18+
First, we'll create a project root directory (you can choose the name):
19+
20+
```bash
21+
mkdir blackholio
22+
cd blackholio
23+
```
24+
25+
We'll start by populating the client directory.
26+
27+
## Setting up the Tutorial Unreal Project
28+
29+
In this section, we will guide you through the process of setting up a Unreal Project that will serve as the starting point for our tutorial. By the end of this section, you will have a basic Unreal project and be ready to implement the server functionality.
30+
31+
### Step 1: Create a Blank Unreal Project
32+
33+
SpacetimeDB supports Unreal version `5.6`. See [the overview](.) for more information on specific supported versions.
34+
35+
Launch Unreal 5.6 and create a new project by selecting Games from the Unreal Project Browser.
36+
37+
> ⚠️ Important: Select the **Blank** template and in **Project Defaults** select **C++**.
38+
39+
For **Project Name** use `client_unreal`.
40+
For **Project Location**, use your `blackholio` directory (created in the previous step).
41+
42+
Click **Create** to generate the blank project.
43+
44+
![Create Blank Project](https://tmp-unreal-engine-tutorial-images.nyc3.digitaloceanspaces.com/part-1-01-create-project.png)
45+
46+
### Import the SpacetimeDB Unreal SDK
47+
48+
While the SpacetimeDB Unreal client SDK is in preview releases, it can only be installed from GitHub:
49+
50+
> https://github.com/clockworklabs/SpacetimeDB/tree/master/sdks/unreal/src
51+
52+
Once the SDK is stabilized, we'll find a more ergonomic way to distribute it.
53+
54+
> **Note:** Before beginning make sure to close the Unreal project and IDE.
55+
56+
#### Installation steps
57+
58+
1. Navigate to your Unreal project directory and create a `Plugins` folder if it doesn’t already exist:
59+
```bash
60+
cd client_unreal
61+
mkdir Plugins
62+
```
63+
2. Download or clone the SDK from GitHub and copy the SpacetimeDbSdk folder into your new Plugins directory.
64+
- This should create `/client_unreal/Plugins/SpacetimeDbSdk`.
65+
3. In the root of the Unreal project, right click the client_unreal.uproject and select **Generate Visual Studio project files**. On Windows 11 you may need to expand **Show more options** to select the generate option.
66+
67+
![Generate project files](https://tmp-unreal-engine-tutorial-images.nyc3.digitaloceanspaces.com/part-1-02-01-generate-project.png)
68+
![Generate project files](https://tmp-unreal-engine-tutorial-images.nyc3.digitaloceanspaces.com/part-1-02-02-generate-project.png)
69+
70+
### Create the GameManager Actor
71+
72+
1. Open the `client_unreal` project in your IDE (Visual Studio or JetBrains Rider) and run the project to launch the Unreal Editor.
73+
- This will enable **Live Coding**, making the workflow a bit smoother.
74+
- Unreal will prompt you to build the `SpacetimeDbSdk` plugin. Do so.
75+
2. Open **Tools -> New C++ Class** in the top menu, select **Actor** as the parent and click **Next**
76+
3. Select **Public** Class Type
77+
4. Name the class `GameManager`.
78+
79+
The `GameManager` class will be where we will put the high level initialization and coordination logic for our game.
80+
81+
> **Note:** In a production Unreal project, you would typically implement this logic in a Subsystem. For simplicity, this tutorial uses a singleton actor.
82+
83+
### Set Up the Level
84+
85+
Set up the empty level, add the new `GameManager` to the level, and add lighting.
86+
87+
1. **Create a new level**
88+
- Open **File -> New Level** in the top menu, select **Empty Level**, and click **Create**.
89+
- Save the level and name it `Blackholio`.
90+
91+
2. **Create a GameManager Blueprint**
92+
- In the **Content Drawer**, click **Add**, then select **Blueprint -> Blueprint Class**.
93+
- Expand **All Classes**, search for **GameManager**, highlight it, and click **Select**.
94+
- Name the blueprint `BP_GameManager`.
95+
96+
![Pick Parent Class](https://tmp-unreal-engine-tutorial-images.nyc3.digitaloceanspaces.com/part-1-03-create-blueprint.png)
97+
98+
3. **Update Maps & Modes**
99+
- Open **Edit -> Project Settings** in the top menu, then select **Project -> Maps & Modes** on the left.
100+
- Set **Editor Startup Map** to `Blackholio`.
101+
- Set **Game Default Map** to `Blackholio`.
102+
103+
4. **Add to the Level**
104+
- Drag the `BP_GameManager` blueprint from the **Content Drawer** into the scene view.
105+
106+
5. **Add a Directional Light**
107+
- Click **Add** in the top toolbar, then select **Lights -> Directional Light**.
108+
- Set **Rotation** to -105.0, -31.0, -14.0.
109+
110+
6. **Add a Post Process Volume**
111+
- Click **Add** in the top toolbar, then select **Volumes -> Post Process Volume**.
112+
- Enable and set **Exposure -> Exposure Compensation** to 0.0.
113+
- Enable and set **Exposure -> Min EV100** to 1.0.
114+
- Enable and set **Exposure -> Max EV100** to 1.0.
115+
- Enable **Post Process Volume Settings -> Infinite Extend (Unbounded)**.
116+
117+
### Add a Simple GameMode
118+
119+
Create a simple GameMode to tweak the startup settings and connect it to the World Settings.
120+
121+
1. **Create the C++ class**
122+
- Open **Tools -> New C++ Class** in the top menu, select **GameModeBase** as the parent, and click **Next**.
123+
- Select **Public** as the class type.
124+
- Name the class `BlackholioGameMode`.
125+
126+
2. **Create a GameMode Blueprint**
127+
- In the **Content Drawer**, click **Add**, then select **Blueprint -> Blueprint Class**.
128+
- Expand **All Classes**, search for `BlackholioGameMode`, highlight it, and click **Select**.
129+
- Name the blueprint `BP_BlackholioGameMode`.
130+
131+
3. **Update World Settings**
132+
- Open **Window -> World Settings** in the top menu.
133+
- Change **GameMode Override** from **None** to `BP_BlackholioGameMode`.
134+
- Save the level.
135+
136+
At this point, the foundation of the Unreal project is set up. Pressing Play will show a blank screen, but the game should start without errors. Next, we’ll create the SpacetimeDB server module so we have something to connect to.
137+
138+
### Create the Server Module
139+
140+
We've now got the very basics set up. In [part 2](part-2) you'll learn the basics of how to create a SpacetimeDB server module and how to connect to it from your client.

0 commit comments

Comments
 (0)