Skip to content

Commit deded8f

Browse files
First round of changes from John's review
1 parent 65ef814 commit deded8f

11 files changed

Lines changed: 46 additions & 25 deletions

File tree

docs/docs/nav.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ const nav = {
2828
page('2 - Connecting to SpacetimeDB', 'unreal/part-2', 'unreal/part-2.md'),
2929
page('3 - Gameplay', 'unreal/part-3', 'unreal/part-3.md'),
3030
page('4 - Moving and Colliding', 'unreal/part-4', 'unreal/part-4.md'),
31-
page('Reference', 'unreal/reference', 'unreal/reference.md'),
3231
section('CLI Reference'),
3332
page('CLI Reference', 'cli-reference', 'cli-reference.md'),
3433
page(
@@ -66,6 +65,7 @@ const nav = {
6665
'sdks/typescript/quickstart.md'
6766
),
6867
page('TypeScript Reference', 'sdks/typescript', 'sdks/typescript/index.md'),
68+
page('Reference', 'unreal/reference', 'unreal/reference.md'),
6969
section('SQL'),
7070
page('SQL Reference', 'sql', 'sql/index.md'),
7171
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/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Need help with the tutorial or CLI commands? [Join our Discord server](https://d
44

55
In this tutorial you'll learn how to build a small-scoped MMORPG 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).
66

7-
By the end, you should have a basic understanding of what SpacetimeDB offers for developers making multiplayer games.
7+
By the end, you should have a basic understanding of what SpacetimeDB offers for developers making multiplayer games.
88

99
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.
1010

File renamed without changes.
5.4 KB
Loading

docs/docs/unreal/part-1.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Need help with the tutorial? [Join our Discord server](https://discord.gg/spacet
88
99
## Prepare Project Structure
1010

11+
> **NOTE:** Ensure you have SpacetimeDB version 1.4.0 installed to enable Unreal Engine code generation support.
12+
1113
This project is separated into two subdirectories;
1214

1315
1. Server (module) code
@@ -49,33 +51,38 @@ While the SpacetimeDB Unreal client SDK is in preview releases, it can only be i
4951
5052
Once the SDK is stabilized, we'll find a more ergonomic way to distribute it.
5153

52-
Before beginning make sure to close the Unreal project and IDE.
54+
> **Note:** Before beginning make sure to close the Unreal project and IDE.
5355
54-
Add the SpacetimeDB Unreal SDK by first adding a new plugin folder:
55-
```bash
56-
cd client_unreal
57-
md Plugins
58-
```
59-
Copy the SpacetimeDbSdk to the new Plugins folder. This should create `/client_unreal/Plugins/SpacetimeDbSdk`.
56+
#### Installation steps
6057

61-
In the root of the Unreal project, right click the client_unreal.uproject and select **Generate Visual Studio project files**.
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.
6266

63-
![Generate project files](./part-1-02-generate-project.png)
67+
![Generate project files](./part-1-02-01-generate-project.png)
68+
![Generate project files](./part-1-02-02-generate-project.png)
6469

6570
### Create the GameManager Actor
6671

67-
1. Open the `client_unreal` project. Unreal will prompt you to build the `SpacetimeDbSdk` plugin. Do so.
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.
6875
2. Open **Tools -> New C++ Class** in the top menu, select **Actor** as the parent and click **Next**
6976
3. Select **Public** Class Type
7077
4. Name the class `GameManager`.
7178

7279
The `GameManager` class will be where we will put the high level initialization and coordination logic for our game.
7380

74-
> Note: In a production Unreal project, you would typically implement this logic in a Subsystem. For simplicity, this tutorial uses a singleton actor.
81+
> **Note:** In a production Unreal project, you would typically implement this logic in a Subsystem. For simplicity, this tutorial uses a singleton actor.
7582
7683
### Set Up the Level
7784

78-
Set up the basic level, add the new `GameManager` to the level, and add lighting.
85+
Set up the empty level, add the new `GameManager` to the level, and add lighting.
7986

8087
1. **Create a new level**
8188
- Open **File -> New Level** in the top menu, select **Empty Level**, and click **Create**.

docs/docs/unreal/part-2.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,11 +438,13 @@ Let's generate our types for our module. In the `blackholio/server-csharp` direc
438438
:::
439439

440440
```sh
441-
spacetime generate --lang unrealcpp --uproject-dir ../client_unreal --project-path ./
441+
spacetime generate --lang unrealcpp --uproject-dir ../client_unreal --project-path ./ --module-name client_unreal
442442
```
443443

444444
This will generate a set of files in the `client_unreal/Source/client_unreal/Private/ModuleBindings` and `client_unreal/Source/client_unreal/Public/ModuleBindings` directories which contain the code generated types and reducer functions that are defined in your module, but usable on the client.
445445

446+
> **Note:** `--uproject-dir` is straightforward as the path to the .uproject file. `--module-name` is the name of the Unreal module which in most projects is the name of the project, in this case `client_unreal`.
447+
446448
```
447449
├── Reducers
448450
│ └── Connect.g.h
@@ -467,7 +469,7 @@ This will also generate a file in the `client_unreal/Source/client_unreal/Privat
467469

468470
### Connecting to the Database
469471

470-
Update `client_unreal.Build.cs` to include the `SpacetimeDbSdk`. Add `SpacetimeDbSdk` to `PublicDependencyModuleNames`, and confirm that `PrivateDependencyModuleNames` includes the following modules for current and future needs:
472+
Update `client_unreal.Build.cs` to include the `SpacetimeDbSdk`. Add `SpacetimeDbSdk` and `Paper2D` to `PublicDependencyModuleNames`, and confirm that `PrivateDependencyModuleNames` includes the following modules for current and future needs:
471473

472474
```cpp
473475
PublicDependencyModuleNames.AddRange(new string[]

docs/docs/unreal/part-3.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,6 @@ public static void Disconnect(ReducerContext ctx)
553553
```
554554
:::
555555

556-
557556
Finally, publish the new module to SpacetimeDB with this command:
558557

559558
```sh
@@ -562,6 +561,8 @@ spacetime publish --server local blackholio --delete-data
562561

563562
Deleting the data is optional in this case, but in case you've been messing around with the module we can just start fresh.
564563

564+
> **Note:** When using `--delete-data`, SpacetimeDB will prompt you to confirm the deletion. Enter **y** and press **Enter** to proceed.
565+
565566
### Creating the Arena
566567

567568
With the server logic in place to spawn food and players, extend the Unreal client to display the current state.
@@ -588,6 +589,17 @@ Add the `SetupArena` and `CreateBorderCube` methods and properties to your `Game
588589
/* Border */
589590
```
590591
592+
Next, we'll need to make a few updates in `GameManager.cpp`.
593+
594+
First, update the includes:
595+
596+
```cpp
597+
#include "GameManager.h"
598+
#include "Components/InstancedStaticMeshComponent.h"
599+
#include "Connection/Credentials.h"
600+
#include "ModuleBindings/Tables/ConfigTable.g.h"
601+
```
602+
591603
The `AGameManager()` constructor in `GameManager.cpp` includes an `InstancedStaticMeshComponent` to set up the cube. Update the constructor as follows:
592604

593605
```cpp
@@ -1334,12 +1346,12 @@ void APlayerPawn::Tick(float DeltaTime)
13341346
Target = { CoM.X, 1.f, CoM.Z };
13351347
}
13361348
}
1337-
const FVector NewLoc = FMath::VInterpTo(GetActorLocation(), Target, DeltaTime, 6.f);
1338-
SetActorLocation(Target);
1349+
const FVector NewLoc = FMath::VInterpTo(GetActorLocation(), Target, DeltaTime, 120.f);
1350+
SetActorLocation(NewLoc);
13391351
}
13401352
```
13411353
1342-
### Spawning
1354+
### Spawning Blueprints
13431355
13441356
Update `GameManager.h` to support spawning Blueprints.
13451357
Make the following edits to the file:
@@ -1675,7 +1687,7 @@ At this point, you may need to regenerate your bindings the following command fr
16751687
:::
16761688
16771689
```sh
1678-
spacetime generate --lang unrealcpp --uproject-dir ../client_unreal --project-path ./
1690+
spacetime generate --lang unrealcpp --uproject-dir ../client_unreal --project-path ./ --module-name client_unreal
16791691
```
16801692

16811693
The last step is to call the `enter_game` reducer on the server, passing in a username for the player.

docs/docs/unreal/part-4.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ spacetime publish --server local blackholio --delete-data
342342
Regenerate your server bindings with:
343343

344344
```sh
345-
spacetime generate --lang unrealcpp --uproject-dir ../client_unreal --project-path ./
345+
spacetime generate --lang unrealcpp --uproject-dir ../client_unreal --project-path ./ --module-name client_unreal
346346
```
347347

348348
### Moving on the Client

docs/docs/unreal/reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Replace:
3131

3232
- `<uproject_directory>` with the path to your Unreal project directory (containing the `.uproject` file)
3333
- `<module_path>` with the path to your SpacetimeDB module
34-
- `<module_name>` with the name of your module
34+
- `<module_name>` with the name of your Unreal module, typically the name of the project
3535

3636
**Example:**
3737

0 commit comments

Comments
 (0)