Godot csharp and gdextension

From makifbaysal/tasktrooper · View interactive version

Godot csharp and gdextension is an AI agent skill from the GitHub repository makifbaysal/tasktrooper. Use when a Godot project uses or considers C# (.NET) or native code - when C# is the right call and its export limits (no web export), C# node patterns with generated SignalName/StringName caching, plain C# rule libraries tested with dotnet test, and GDExtension (godot-cpp, godot-rust) pinning and b

How to use this skill

Skill file

Godot C# and GDExtension

Overview

Godot runs GDScript, C# (.NET) and native code through GDExtension (C++ via godot-cpp, Rust via godot-rust, and others). Each has a cost: C# needs the .NET build of the editor and cannot export to the web; GDExtension needs a native build per target platform. The repository's existing choice wins; adding a second language is a decision, not a convenience.

Core principle: GDScript by default, C# where the project already is .NET or the team needs it and the web is not a target, GDExtension only for measured hot spots or native libraries.

When which

| Need | Choice |

|---|---|

| Web export required | GDScript (C# web export is still unsupported in Godot 4.7) |

| Team is C#, heavy algorithms, .NET libraries | C# — on desktop and mobile targets |

| A measured hot loop GDScript cannot meet the budget with | GDExtension (C++ or Rust), or move it to C# if the project is .NET |

| Binding an existing native SDK | GDExtension |

Mixing GDScript and C# in one project works (cross-language calls go through Call, Get, signals), but keep one language per feature and a clear boundary.

C# nodes

using Godot;

public partial class Player : CharacterBody2D
{
    [Signal] public delegate void HealthChangedEventHandler(int current, int maximum);

    [Export] public PlayerDefinition Definition { get; set; }

    static readonly StringName JumpAction = "jump";
    static readonly StringName MoveLeft = "move_left";
    static readonly StringName MoveRight = "move_right";

    AnimatedSprite2D _sprite;
    int _health;

    public override void _Ready()
    {
        _sprite = GetNode<AnimatedSprite2D>("AnimatedSprite2D");
        _health = Definition.MaxHealth;
    }

    public override void _PhysicsProcess(double delta)
    {
        var v = Velocity;
        v.X = Input.GetAxis(MoveLeft, MoveRight) * Definition.MoveSpeed;
        if (IsOnFloor() && Input.IsActionJustPressed(JumpAction)) v.Y = -Definition.JumpSpeed;
        v.Y += Definition.Gravity * (float)delta;
        Velocity = v;
        MoveAndSlide();
    }

    public void TakeDamage(int amount)
    {
        _health = Mathf.Max(0, _health - amount);
        EmitSignal(SignalName.HealthChanged, _health, Definition.MaxHealth);
    }
}

Rules in a plain library

Game.Core/          net8.0 class library — no Godot reference; rules, math, state machines
Game.Core.Tests/    xUnit or NUnit, references Game.Core
Game/               the Godot project (.csproj references Game.Core)

dotnet test Game.Core.Tests runs anywhere, with or without Godot installed (testable-game-logic). Engine-level C# tests go through gdUnit4Net (godot-testing).

GDExtension

; res://bin/pathfinding.gdextension
[configuration]
entry_symbol = "pathfinding_library_init"
compatibility_minimum = "4.7"

[libraries]
macos.debug = "res://bin/libpathfinding.macos.template_debug.framework"
macos.release = "res://bin/libpathfinding.macos.template_release.framework"
linux.debug.x86_64 = "res://bin/libpathfinding.linux.template_debug.x86_64.so"
windows.debug.x86_64 = "res://bin/pathfinding.windows.template_debug.x86_64.dll"

Export limits to state up front

Common Mistakes

Red Flags

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.