Godot C# / .NET (4.x)
Write Godot game code in C#: node subclasses, the engine lifecycle, exports, signals as events, and GDScript interop. Targets Godot 4.7 (.NET / C#) and .NET 8.
When to use
- Use when scripting a Godot game in C# (
.cs+.csproj), translating GDScript idioms to C#, exposing[Export]fields, or wiring[Signal]delegates and GetNode<T>.
When not to use: GDScript-specific syntax → godot-gdscript; engine concepts that
are language-neutral (scenes, physics, animation) → the relevant godot-* skill. You need
the Godot .NET build + the .NET SDK installed; the standard build can't run C#.
Core workflow
- Use the Godot .NET editor build and install the matching .NET 8 SDK. Creating the first C#
script generates a
.csproj/.sln. Build with the editor ordotnet build. - Every node script is a
partialclass extending a Godot type (the source generator relies onpartial). The file/class name should match the node script. - Override lifecycle methods in PascalCase with
doubledelta:_Ready(),_Process(double delta),_PhysicsProcess(double delta). - Expose tunables with
[Export]; they show in the Inspector like GDScript@export. - Declare signals as
[Signal]delegates namedXxxEventHandler; emit withEmitSignal(SignalName.Xxx, ...)and subscribe with the generated C#event. - Get nodes with
GetNode<T>("Path")(or%Unique), and call into GDScript withCall/Get/Setwhen needed.
Patterns
1. A node script: lifecycle, [Export], GetNode<T>
2. Signals as C# events
3. Instancing a scene in C#
4. Interop with GDScript nodes
Pitfalls
- Forgetting
partial. Withoutpartial, the Godot source generator can't extend the class and[Export]/[Signal]break with confusing build errors. - Wrong method case/signature. C# overrides are
_Ready,_Process(double),_PhysicsProcess(double)— PascalCase anddoubledelta (GDScript uses snake_case andfloat). A mismatched name just won't be called. [Signal]delegate naming. It must end withEventHandler; the engine exposes the signal as the name without that suffix and generatesSignalName.Xand a C#event.GD.PrintvsConsole.WriteLine. UseGD.Print/GD.PrintErrto reach the Godot output panel;Consoleoutput may not appear.- Value-type structs.
Vector2,Color,Transform2Dare structs — mutate a local copy (var v = Velocity; v.X = ...; Velocity = v;); editingVelocity.Xdirectly won't compile/persist. - Needs the .NET build + SDK. The non-.NET editor can't run C#; mismatched/missing .NET SDK causes build failures. Godot 4.7 targets .NET 8; check current platform export notes because Android and other AOT targets can require newer SDK tooling.
QueueFree()vsFree()— same rules as GDScript; preferQueueFree(). Disposed objects throwObjectDisposedExceptionif used after freeing.- Export to some platforms differs for .NET (e.g. extra steps for web/mobile); check the .NET export notes for your target.
References
- For export attribute variants (
[ExportGroup], ranges, typed arrays), async withawait ToSignal(...),Godot.Collectionsvs System collections, custom Resources in C#, and project/build setup, readreferences/csharp-setup-and-interop.md.
Related skills
godot-gdscript— the GDScript equivalents of these patterns.godot-signals-groups— signal/event architecture (language-neutral).godot-resources— data resources; the C#[Export]+Resourcepattern.unity-csharp-scripting— C# in Unity, for developers coming from there.


