본문으로 건너뛰기
Skillpedia
일반 코딩6.6k · #13820

godot-csharp

하는 일

이 스킬은 Godot .NET 빌드를 사용해 Godot 게임 스크립트를 C#으로 작성하는 방법을 설명합니다. GDScript 대신 C#을 선호하여 Godot로 게임을 만드는 사람을 위한 스킬입니다.

사용하는 경우

  • ✓Godot 4 게임의 C# 스크립트를 작성하거나 수정할 때.
  • ✓GDScript 패턴을 C# 코드로 바꾸고 싶을 때.
  • ✓Godot 시그널을 C# 이벤트로 연결하거나 필드를 인스펙터에 노출해야 할 때.

스킬 링크

https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/godot/godot-csharp/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/godot/godot-csharp/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“내 Godot 게임의 플레이어 스크립트를 C#으로 작성해 주세요. 공격을 받으면 움직이고 시그널을 보내도록 해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트에게 노드 스크립트, 생명주기 메서드, 내보내는 필드, 시그널에 대한 Godot C# 규칙을 알려 줍니다. 그래서 코드가 Godot이 기대하는 방식을 따릅니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

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

  1. Use the Godot .NET editor build and install a .NET SDK: 8 or later, and 9 or later if you export to Android. Creating the first C# script generates a .csproj/.sln. Build with the editor or dotnet build.
  2. Every node script is a partial class extending a Godot type (the source generator relies on partial). The file/class name should match the node script.
  3. Override lifecycle methods in PascalCase with double delta: _Ready(), _Process(double delta), _PhysicsProcess(double delta).
  4. Expose tunables with [Export]; they show in the Inspector like GDScript @export.
  5. Declare signals as [Signal] delegates named XxxEventHandler; emit with EmitSignal(SignalName.Xxx, ...) and subscribe with the generated C# event.
  6. Get nodes with GetNode<T>("Path") (or %Unique), and call into GDScript with Call/Get/Set when needed.

Patterns

1. A node script: lifecycle, [Export], GetNode<T>

using Godot;

public partial class Player : CharacterBody2D
{
    [Export] public float Speed = 200.0f;          // editable in the Inspector
    [Export] public float JumpVelocity = -400.0f;

    private const float Gravity = 1200.0f;
    private AnimatedSprite2D _sprite;

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

    public override void _PhysicsProcess(double delta)
    {
        Vector2 v = Velocity;                       // Velocity is a property here
        if (!IsOnFloor())
            v.Y += Gravity * (float)delta;          // delta is double; cast for float math
        if (Input.IsActionJustPressed("jump") && IsOnFloor())
            v.Y = JumpVelocity;

        float dir = Input.GetAxis("move_left", "move_right");
        v.X = dir != 0 ? dir * Speed : Mathf.MoveToward(v.X, 0, Speed);

        Velocity = v;
        MoveAndSlide();                             // no args, like GDScript 4.x
    }
}

2. Signals as C# events

using Godot;

public partial class Health : Node
{
    // Delegate name MUST end with "EventHandler"; generator creates the event + SignalName.
    [Signal] public delegate void HealthChangedEventHandler(int current, int max);

    private int _hp = 100;

    public void TakeDamage(int amount)
    {
        _hp = Mathf.Max(_hp - amount, 0);
        EmitSignal(SignalName.HealthChanged, _hp, 100);   // type-safe signal name
    }

    public override void _Ready()
    {
        HealthChanged += OnHealthChanged;            // subscribe like a normal C# event
    }

    private void OnHealthChanged(int current, int max) => GD.Print($"HP {current}/{max}");
}

3. Instancing a scene in C#

public partial class Spawner : Node2D
{
    // Load once; PackedScene is the C# equivalent of preload's result.
    private readonly PackedScene _bullet = GD.Load<PackedScene>("res://bullet.tscn");

    public void Shoot(Vector2 at)
    {
        var b = _bullet.Instantiate<Node2D>();       // typed instantiate
        b.GlobalPosition = at;
        AddChild(b);
    }
}

4. Interop with GDScript nodes

public override void _Ready()
{
    Node gd = GetNode("GDScriptNode");
    // Call a GDScript method and read/write its properties dynamically.
    gd.Call("take_damage", 10);
    int score = (int)gd.Get("score");
    gd.Set("score", score + 5);
    // Connect to a GDScript signal by name:
    gd.Connect("died", Callable.From(OnDied));
}

private void OnDied() => GD.Print("entity died");

Pitfalls

  • Forgetting partial. Without partial, 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
자주 묻는 질문

C#을 사용하려면 특별한 버전의 Godot이 필요한가요?

네. 이 스킬은 Godot .NET 빌드 에디터와 .NET SDK가 필요하다고 설명합니다. 일반 빌드는 C# 코드를 실행할 수 없기 때문입니다.

C#과 GDScript를 같은 프로젝트에서 함께 쓸 수 있나요?

네. 이 스킬은 C# 코드가 GDScript 코드를 호출하고, 그 반대도 가능한 방법을 다룹니다.

이 스킬은 씬 구성도 다루나요?

깊게 다루지는 않습니다. 씬과 노드 구조는 별도의 Godot 스킬에서 다루고, 이 스킬은 C# 코드에 집중합니다.

상세 정보

작성자의 원본 설명

Use C#/.NET in Godot 4.7: partial classes extending nodes, the PascalCase lifecycle (_Ready/_Process/_PhysicsProcess), [Export] fields, [Signal] delegates as C# events, type-safe node lookup, and calling between C# and GDScript. Use when writing Godot game code in C# (.cs files, .csproj), needing the Godot .NET build, converting GDScript patterns to C#, or wiring Godot signals as C# events.

repo: gamedev-skills/awesome-gamedev-agent-skills

인기도

GitHub 스타
6.6k
순위
#13820
라이선스
Apache-2.0
업데이트
2026. 10. 28.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬