SetNet.Godot
1.1.0
dotnet add package SetNet.Godot --version 1.1.0
NuGet\Install-Package SetNet.Godot -Version 1.1.0
<PackageReference Include="SetNet.Godot" Version="1.1.0" />
<PackageVersion Include="SetNet.Godot" Version="1.1.0" />
<PackageReference Include="SetNet.Godot" />
paket add SetNet.Godot --version 1.1.0
#r "nuget: SetNet.Godot, 1.1.0"
#:package SetNet.Godot@1.1.0
#addin nuget:?package=SetNet.Godot&version=1.1.0
#tool nuget:?package=SetNet.Godot&version=1.1.0
<p align="center"> <img src="https://raw.githubusercontent.com/Povstalez/SetNet/master/assets/icon.png" alt="SetNet" width="96"> </p>
SetNet.Godot
Godot 4 (C#) binding for SetNet.
SetNet is engine-agnostic, but two things always trip up an engine integration: message handlers run on background threads (and Godot's scene tree may only be touched on the main thread), and the core math types (Vec2/Vec3/Quat) aren't Godot's Vector2/Vector3/Quaternion. This package solves both:
GodotMainThreadDispatcher— marshal work from SetNet's receive/handler threads onto Godot's main thread, drained once per frame in_Process.- math conversions —
ToNet()/ToGodot()extension methods between theSetNet.StateSyncmath types and Godot's vector/quaternion types.
Everything above the transport — handlers, rooms, RPC, state sync — is unchanged; this is just the glue for a Godot 4 C# project.
Install
dotnet add package SetNet
dotnet add package SetNet.StateSync
dotnet add package SetNet.Godot
Depends on GodotSharp and SetNet.StateSync. Requires Godot 4's .NET build (the C#/Mono edition).
Usage
SetNet handlers run off the main thread. Enqueue the scene-tree work with the dispatcher inside your handler, then drain it once per frame from a Node:
using Godot;
using SetNet.Godot;
using SetNet.StateSync;
public partial class NetworkedPawn : Node3D
{
private Vec3 _latest; // last replicated position, written from a background thread
// Called from a StateSync (or message) handler running off the main thread.
// Never touch a Node here — just stash the data.
public void OnReplicated(Vec3 position) =>
GodotMainThreadDispatcher.Shared.Post(() => _latest = position);
public override void _Process(double delta)
{
// run everything queued from background threads, on the main thread:
GodotMainThreadDispatcher.Shared.Drain();
// now it's safe to apply the replicated state to the scene tree:
Position = _latest.ToGodot();
}
}
Marshalling from a handler
// inside a background-thread handler — never touch a Node directly here:
GodotMainThreadDispatcher.Shared.Post(() =>
{
GetNode<Label>("Hud/Status").Text = "connected";
});
// or await the result on the caller:
await GodotMainThreadDispatcher.Shared.PostAsync(() => SpawnPlayer(id));
Math conversions
Vec3 net = transform.Origin.ToNet(); // Godot Vector3 → core Vec3
Vector3 pos = net.ToGodot(); // core Vec3 → Godot Vector3
Vec2 v2 = velocity.ToNet(); // Vector2 ↔ Vec2
Quat rot = Quaternion.Identity.ToNet(); // Quaternion ↔ Quat
API
GodotMainThreadDispatcher:
| Member | Purpose |
|---|---|
static GodotMainThreadDispatcher Shared |
process-wide shared dispatcher |
void Post(Action action) |
queue an action to run on the next Drain() |
Task PostAsync(Action action) |
queue an action; the task completes (or faults) once it has run |
void Drain() |
run all queued actions — call once per frame from _Process(double delta) |
GodotConversions (extension methods): ToNet() / ToGodot() between Vec2↔Vector2, Vec3↔Vector3, Quat↔Quaternion.
Notes
- Drain every frame. If you never call
Drain(), posted actions queue up and never execute. Call it from a single long-livedNode's_Process(e.g. an autoload singleton). Drain()isolates faults — one throwing callback won't stop the rest of the queue that frame.- Threading rule. Only touch the scene tree (nodes, transforms, signals) from the main thread. Do computation in your handler,
Postthe scene-tree write. - Web/HTML5 exports have no threads or raw sockets — pair with
SetNet.WebSocketsto run overws://. - Requires Godot 4's .NET build; not for the GDScript-only edition.
Documentation & source
- 🐙 https://github.com/Povstalez/SetNet — full module catalog in docs/MODULES.md
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- GodotSharp (>= 4.4.1)
- SetNet.StateSync (>= 1.1.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on SetNet.Godot:
| Package | Downloads |
|---|---|
|
SetNet.StateSync.Godot
Godot 4 (C#) components for SetNet state replication: NetworkObject + NetworkTransform / NetworkRigidBody / NetworkAnimationPlayer / NetworkBehaviour, and a NetworkManager node that spawns/despawns networked scenes and drives interpolation. The engine-agnostic replication (SetNet.StateSync) is unchanged; this is the Godot binding. Depends on SetNet.StateSync + SetNet.Godot + GodotSharp. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.0 | 158 | 7/2/2026 |