Skip to content

Godot SDK and Blackholio tutorial#4920

Open
lisandroct wants to merge 18 commits intomasterfrom
lisandro/godot-blackholio
Open

Godot SDK and Blackholio tutorial#4920
lisandroct wants to merge 18 commits intomasterfrom
lisandro/godot-blackholio

Conversation

@lisandroct
Copy link
Copy Markdown
Contributor

@lisandroct lisandroct commented Apr 30, 2026

Description of Changes

Very small additions to the C# SDK specific for Godot.
I wrote the Godot Blackholio tutorial and updated the Unity one.
I added the image assets necessary for the tutorial.
I added the files for the Godot demo.

API and ABI breaking changes

No breaking changes.

Expected complexity level and risk

  1. There's really no risk for current systems or projects, it's all new additions to support nicely(-ish) Godot, new Blackholio demo for Godot and updates to the tutorials.

Testing

  • Follow the tutorial and verify everything works.
  • Build for Windows and verify it works.
  • Build for Linux and verify it works.
  • Build SDK
  • Publish to Nuget

@lisandroct lisandroct marked this pull request as draft April 30, 2026 14:29
@lisandroct lisandroct changed the title Lisandro/godot blackholio Godot SDK and Blackholio tutorial Apr 30, 2026
@lisandroct lisandroct marked this pull request as ready for review April 30, 2026 14:37
Copy link
Copy Markdown
Contributor

@rekhoff rekhoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was only able to get part-way through docs/docs/00100-intro/00300-tutorials/00500-godot-tutorial/00300-part-2.md before hitting a blocker with the implementation.
The tutorial so far it looks good with only some minor nits, but the NuGet package issue will need to get addressed before I can finish reviewing.

Comment thread docs/docs/00100-intro/00300-tutorials/00500-godot-tutorial/00200-part-1.md Outdated
}
}
}
#elif GODOT
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe this will work to allow Godot to have code only relevant to it within the NuGet packages. Unity is able to get away with unique build flags because we have Unity developers Import the SpacetimeDB SDK using the C# SDK repo. This means for Unity developers, the original code is intact and constants like UNITY_5_3_OR_NEWER and UNITY_EDITOR are evaluated locally. Only the SpacetimeDB.BSATN.Codegen.dll and SpacetimeDB.BSATN.Runtime.dll are pre-built head of time.

When we publish the NuGet packages for the general C# developers, that will strip out the GODOT build flag because it's not included as a constant during compilation. If we did include it, that would make it available to all SDK users (which of course would break things since it's specifically imports using Godot.

We'll likely need another approch than using GODOT build flags, or would need to make a custom target framework specifically for this.

For additional context, if we follow the tutorial, but point at a local NuGet package build from the lisandro/godot-blackholio branch, we'd get the errors like:

GameManager.cs(43,23): Error CS0117 : 'AuthToken' does not contain a definition for 'TryGetToken'
GameManager.cs(49,9): Error CS0103 : The name 'STDBUpdateManager' does not exist in the current context

And again, this is because the code is getting stripped out.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering if this was going to work. I couldn't get my local NuGet working because I was missing what you dm me yesterday.
I guess the onlybest solution we have is to compile with the GODOT preprocessor flag and publish a different NuGet package.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my most-recent testing, I was able to rebuild the NuGet packages with the SpacetimeDB.ClientSDK.Godot.2.1.0.nupkg package that is now getting generated.

Comment thread sdks/csharp/src/GodotDebugLogger.cs
Comment thread sdks/csharp/src/ISpacetimeDBLogger.cs
Comment thread sdks/csharp/src/STDBUpdateManager.cs
@lisandroct lisandroct force-pushed the lisandro/godot-blackholio branch from dba5046 to f9ee392 Compare May 5, 2026 16:24
@lisandroct lisandroct requested a review from rekhoff May 5, 2026 16:28
Copy link
Copy Markdown
Contributor

@rekhoff rekhoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested the C# Server implementation instructions of the Godot tutorial and left my comments below.
I have also tested the client-godot version in the demo folder and confirmed it works as intended.


Let's also create an `EntityController` script which will serve as a base class for both our `CircleController` and `FoodController` classes since both `Circle`s and `Food` are entities.

Create a new C# script called `EntityController.cs` and replace its contents with:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When creating this EntityController.cs script using Godot's Create Script dialog, you can't select Circle2D as what it Inherits from.
Since we aren't really asking them to define inheritance elsewhere and the code we copy in puts the correct inheritance in place anyway, this is just an optional thing.

If actually wanted them to be able to select our C# classes in this manner though, by having the Circle2D class defined with the [GlobalClass] attribute. Documentation around this is at https://docs.godotengine.org/en/4.4/tutorials/scripting/c_sharp/c_sharp_global_classes.html
With that in place, if we then press play once, so the project rebuilds, Circle2D shows up under Node2D as something that can be inherited from.

Since we don't actually ask them to do this, it would purely be for teaching users how to interact between the Godot Editor side of the house, and C# backend code that works with SpacetimeDB.

Comment on lines +336 to +338
```csharp
public partial struct MoveAllPlayersTimer
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```csharp
public partial struct MoveAllPlayersTimer
{
```csharp
[Table(Accessor = "move_all_players_timer", Scheduled = nameof(MoveAllPlayers), ScheduledAt = nameof(scheduled_at))]
public partial struct MoveAllPlayersTimer
{

Without this, we'll get an error on the C# step that reads

Add the following to your Init reducer to schedule the MoveAllPlayers reducer to run every 50 milliseconds.

Comment on lines +19 to +20
<AssemblyVersion>2.1.0</AssemblyVersion>
<Version>2.1.0</Version>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<AssemblyVersion>2.1.0</AssemblyVersion>
<Version>2.1.0</Version>
<AssemblyVersion>2.2.0</AssemblyVersion>
<Version>2.2.0</Version>

As a note, we'll need to make sure the process we are using to update version numbers includes SpacetimeDB.ClientSDK.Godot.csproj going forward. Since that last update was pulled in from the master branch, the other NuGet packages are all on 2.2.0 while the Godot was still on 2.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants