Csharp Godot logo

Csharp Godot

Community
jame581
csharp-godot

Use when working with C# in Godot — conventions, GodotSharp API differences from GDScript, project setup, and interop

Overview

Publisherjame581
RepositoryGodotPrompter
Skill namecsharp-godot
Stars
808
Forks
47
Bundled files
1
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by jame581 on GitHub. Read the source before you install it.

Installation

Install the Csharp Godot AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/jame581/GodotPrompter/tree/master/skills/csharp-godot
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/jame581/GodotPrompter.git /tmp/GodotPrompter
mkdir -p .claude/skills
cp -r /tmp/GodotPrompter/skills/csharp-godot .claude/skills/csharp-godot
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Csharp Godot in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Csharp Godot on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Csharp Godot is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

C# in Godot 4.3+

This skill covers C#-specific conventions, API differences from GDScript, project setup, and interop patterns. All examples are C# only. Target Godot 4.3+ with the GodotSharp NuGet package.

Related skills: csharp-signals for C# signal patterns, godot-project-setup for C# project scaffolding, godot-testing for C# testing with gdUnit4, gdextension for native C++ when C# is not enough, multithreading for C# concurrency.


1. C# vs GDScript Syntax Comparison

GDScriptC# EquivalentNotes
var x = 5var x = 5; or typed int x = 5;C# var infers type at compile time
func MyMethod() -> void:public void MyMethod() { }Methods are PascalCase in C#
signal health_changed(amount: int)[Signal] delegate void HealthChangedEventHandler(int amount);Must use EventHandler suffix
@export var speed: float = 100.0[Export] public float Speed { get; set; } = 100f;PascalCase, property syntax
@onready var label = $Labelprivate Label _label; + _label = GetNode<Label>("Label"); in _Ready()No @onready equivalent; use _Ready()
match value:switch (value) { case X: break; }C# switch also supports pattern matching
class_name MyClass[GlobalClass] public partial class MyClass : GodotObject { }Requires [GlobalClass] attribute
extends Nodepublic partial class MyScript : Node { }Inheritance via :
preload("res://scene.tscn")GD.Load<PackedScene>("res://scene.tscn")Loaded at runtime, not compile time
push_error("msg")GD.PushError("msg");Prints to Godot error log
print("msg")GD.Print("msg");Also: GD.PrintS(), GD.PrintT()
node is CharacterBody2Dnode is CharacterBody2DSame keyword, same semantics
node as CharacterBody2Dnode as CharacterBody2DReturns null on failure in both
await signal_nameawait ToSignal(source, SignalName.X);Must use ToSignal() wrapper
ArrayGodot.Collections.ArrayNot System.Collections.Generic.List<T>
DictionaryGodot.Collections.DictionaryNot System.Collections.Generic.Dictionary<K,V>

2. Project Setup

.csproj and Solution

Godot auto-generates the .csproj when you create the first C# script via Script > New Script > C#. Do not edit the generated file structure manually — let the editor manage it.

MyProject/
├── MyProject.csproj          # Auto-generated, edit only for NuGet packages
├── MyProject.sln             # Auto-generated solution file
├── project.godot
└── scripts/
    └── Player.cs

NuGet Packages

Add packages in MyProject.csproj inside <ItemGroup>:

xml
<Project Sdk="Godot.NET.Sdk/4.3.0">
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <Nullable>enable</Nullable>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
  </PropertyGroup>
  <ItemGroup>
    <!-- Example: add a third-party NuGet package -->
    <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
  </ItemGroup>
</Project>

Run dotnet restore or let the IDE restore automatically after editing.

Godot.NET Preview Bindings (Godot 4.7+)

Godot 4.7's Godot.NET.Sdk accepts an opt-in MSBuild property that switches the project from the classic GodotSharp bindings to the preview Godot.NET bindings (the Godot.Bindings assembly instead of GodotSharp):

xml
<PropertyGroup>
  <EnableGodotDotNetPreview>true</EnableGodotDotNetPreview>
</PropertyGroup>

The preview bindings are experimental — leave the property unset for production projects. See GH-118001.

IDE Setup

IDESetup RequiredNotes
JetBrains RiderInstall Godot plugin (bundled in Rider 2023.3+)Best Godot C# support; debugger works out of the box
VS CodeInstall C# Dev Kit + Godot Tools extensionsRequires launch.json for debugger attachment
Visual StudioInstall Godot Visual Studio extensionWindows only; debugger via Tools > Attach to Process

For all IDEs, open the .sln file (not just a folder) to get full solution resolution.


3. The partial class Requirement

Every class that extends a Godot type must be declared partial. This is not optional.

Why

Godot uses C# source generators to emit the signal registration, property binding, and RPC code alongside your class. Source generators require partial to inject into the same class declaration.

Error When Forgotten

Error CS0260: Missing partial modifier on declaration of type 'Player';
another partial declaration of this type exists.

Or the class compiles but signals and [Export] properties silently fail to register.

Rule

csharp
// CORRECT
public partial class Player : CharacterBody2D { }

// WRONG — will cause source generator errors
public class Player : CharacterBody2D { }

This applies to every class in the inheritance chain that extends a Godot type, including intermediate base classes.


4. Naming Conventions

ElementConventionExample
MethodsPascalCasepublic void TakeDamage(int amount)
PropertiesPascalCasepublic float MaxHealth { get; set; }
Signals (delegate)PascalCase + EventHandler suffixHealthChangedEventHandler
[Export] propertiesPascalCase[Export] public float Speed { get; set; }
Private fields_camelCase with underscore prefixprivate float _currentSpeed;
Local variablescamelCasevar newPosition = ...
ParameterscamelCasevoid SetHealth(int newHealth)
Godot API namesMatch Godot's PascalCase exactlyGlobalPosition not global_position
EnumsPascalCase type, PascalCase membersenum State { Idle, Running, Dead }
ConstantsPascalCase or SCREAMING_SNAKE per team styleconst float MaxSpeed = 200f;

Always match GodotSharp property and method names exactly — they are PascalCase translations of the GDScript snake_case names (e.g. is_on_floor() → IsOnFloor()).


5. Signals in C#

Signals require a delegate declaration with the [Signal] attribute. The delegate name must end with EventHandler.

csharp
using Godot;

public partial class Player : CharacterBody2D
{
    // Declaration
    [Signal] public delegate void HealthChangedEventHandler(int newHealth);
    [Signal] public delegate void DiedEventHandler();

    private int _health = 100;

    public void TakeDamage(int amount)
    {
        _health -= amount;
        EmitSignal(SignalName.HealthChanged, _health);  // Use SignalName.X, not a string
        if (_health <= 0)
            EmitSignal(SignalName.Died);
    }
}

Connecting and Disconnecting

csharp
// Connect with +=
player.HealthChanged += OnHealthChanged;
player.Died += OnPlayerDied;

// Disconnect with -=
player.HealthChanged -= OnHealthChanged;
player.Died -= OnPlayerDied;

// Handler signatures must match the delegate
private void OnHealthChanged(int newHealth) { ... }
private void OnPlayerDied() { ... }

For full signal patterns including one-shot connections, static typed signals, and cross-language signal wiring, see the csharp-signals skill.


6. Async / Await

GDScript's await maps to C#'s await ToSignal(...). Godot signals return a SignalAwaiter that is compatible with C# await.

Awaiting a Godot Signal

csharp
public async void StartCutscene()
{
    // Wait for a timer to finish
    await ToSignal(GetTree().CreateTimer(2.0), Timer.SignalName.Timeout);

    // Wait for an animation to finish
    var anim = GetNode<AnimationPlayer>("AnimationPlayer");
    anim.Play("intro");
    await ToSignal(anim, AnimationPlayer.SignalName.AnimationFinished);

    GD.Print("Cutscene complete");
}

Task-Based Patterns

For CPU-bound work, use Task.Run — but never touch Godot objects from a non-main thread:

csharp
public async void LoadHeavyData()
{
    // Off main thread: pure C# computation only
    var result = await Task.Run(() => ComputeSomethingExpensive());

    // Back on main thread: safe to use Godot API
    ApplyResult(result);
}

private int ComputeSomethingExpensive()
{
    // No Godot API calls here
    return Enumerable.Range(0, 1_000_000).Sum();
}

GDScript await Equivalents

GDScriptC#
await get_tree().create_timer(1.0).timeoutawait ToSignal(GetTree().CreateTimer(1.0), Timer.SignalName.Timeout)
await animation_player.animation_finishedawait ToSignal(animPlayer, AnimationPlayer.SignalName.AnimationFinished)
await signal_nameawait ToSignal(this, SignalName.YourSignal)

7. GDScript Interop

C# calls into GDScript objects with Call, Get, and Set, and GDScript can use a C# class directly when it is registered as a [GlobalClass]. Values cross the boundary as Variant, and the reference lists the marshalling gotchas (null, int[], List<T>).

See references/gdscript-interop.md for the Call/Get/Set examples, the [GlobalClass] pattern, and the Variant marshalling table.


8. Performance

C# vs GDScript

WorkloadWinnerReason
Math-heavy loops (pathfinding, simulation)C# (significantly faster)Compiled JIT vs interpreted GDScript
Large array/collection processingC#Value type arrays avoid boxing
Godot API calls (move_and_slide, etc.)Roughly equalBoth route through the same C++ engine
Scene tree operationsRoughly equalBottleneck is C++ overhead, not language
Rapid prototypingGDScriptLess boilerplate, hot-reload without recompile
Editor tooling (plugins, @tool)GDScriptC# tool scripts require a full build cycle

Guidance

  • Use C# for systems with tight loops: physics solvers, procedural generation, AI decision trees, data processing.
  • Use GDScript for editor plugins, @tool scripts, and rapid iteration on gameplay logic.
  • Mixing languages in the same project is supported — interop cost is minimal for occasional cross-language calls.
  • Avoid Godot.Collections.Array for hot paths; prefer typed arrays (Array<T>) or native C# arrays (T[]) converted at boundaries.
  • StringName lookups are O(1) but StringName construction is not — cache them if created frequently.

9. Common Gotchas

GotchaProblemFix
Variant to C# type conversion(float)someVariant throws if the underlying type is intUse .AsSingle(), .AsInt32(), etc. instead of casts
null vs default(Variant)Godot signals passing no value give default(Variant), not C# nullCheck .VariantType == Variant.Type.Nil
Godot.Collections vs System.CollectionsGodot API methods return Godot.Collections.Array; passing List<T> causes runtime errorAlways use Godot.Collections.Array/Dictionary at Godot API boundaries
Disposing native objectsCalling methods on a freed Godot object throws ObjectDisposedExceptionCheck IsInstanceValid(obj) before use
StringName construction in hot loopsnew StringName("my_signal") allocates each callCache as private static readonly StringName _signalName = "my_signal";
Export array types[Export] public Array Items; exports untyped arrayUse [Export] public Godot.Collections.Array<MyResource> Items { get; set; }
Node path stringsGetNode("../UI/Label") fails silently if the path changesUse GetNode<Label>("%Label") with unique names or typed [Export] node references
partial class forgottenSource generators silently fail; [Export] and [Signal] don't registerEvery class extending a Godot type must be partial
async void vs async Taskasync void swallows exceptionsUse async Task except for top-level event handlers that Godot calls

⚠️ Changed in Godot 4.7: The 4.7 C# assemblies ship several compatibility breaks. Binary-incompatible only (source still compiles — a rebuild suffices): OptimizedTranslation.Generate() now returns bool instead of void (GH-119563). Binary- and source-incompatible (code changes required): Animation.Length changed type metadata from float to double (GH-116394) — the C# property is now double, so float len = anim.Length; no longer compiles — and Control.AccessibilityLive changed enum type from DisplayServer.AccessibilityLiveMode to AccessibilityServer.AccessibilityLiveMode (GH-116839) — update declarations to the AccessibilityServer enum. Source-incompatible (existing binaries still load): RichTextLabel.ImageUpdateMask.UpdateWidthInPercent was renamed to UpdateWidthUnit (GH-112617), and the EditorSceneFormatImporter IMPORT_* constants moved into the ImportFlags enum (GH-115788). Removed: AudioEffectSpectrumAnalyzer.TapBackPos (GH-114355). Rebuild against 4.7 and fix the affected symbols. See the 4.7 migration guide.


10. Checklist

  • Every class extending a Godot type is declared partial
  • Method names match GodotSharp PascalCase (e.g. _Ready, _PhysicsProcess, IsOnFloor())
  • [Export] properties are PascalCase and use property syntax ({ get; set; })
  • Signal delegates end with EventHandler and use EmitSignal(SignalName.X)
  • Signals connected with += and disconnected with -= when no longer needed
  • await ToSignal(...) used for Godot signals — not raw Task.Delay for game timing
  • Godot.Collections.Array/Dictionary used at Godot API boundaries, not System.Collections types
  • IsInstanceValid(obj) checked before using any potentially freed Godot object
  • StringName instances cached if constructed in loops or frequently called methods
  • No Godot API calls inside Task.Run(...) callbacks — all engine calls happen on the main thread
  • .csproj opened via the .sln file in the IDE for full solution resolution
  • C# used for computation-heavy systems; GDScript retained for editor tooling and @tool scripts

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Csharp Godot AI skill do?

Use when working with C# in Godot — conventions, GodotSharp API differences from GDScript, project setup, and interop

Why use Csharp Godot on TypingMind?

Because you install it once and use it with any model. Csharp Godot is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Csharp Godot in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/jame581/GodotPrompter/tree/master/skills/csharp-godot. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Csharp Godot?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Csharp Godot?

As many as you like. As long as a model supports skills, you can use Csharp Godot with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Csharp Godot AI skill free?

Yes. It is published on GitHub by jame581 under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇