本文へスキップ
Skillpedia
一般的なプログラミング48k · #4766

godot-4-migration

できること

このガイドは、Godot 3で作ったゲームをGodot 4に移行するのに役立ちます。コードの書き方の変更点(GDScript 2.0)、アニメーションの使い方(Tween)、ゲームの設定画面に表示される変数の宣言方法(エクスポート)を説明します。

使う場面

  • ✓Godot 3からGodot 4へゲームを移行するとき。
  • ✓アップデート後にゲームのコードが動かなくなったとき。
  • ✓アニメーションの仕組みを変更する必要があるとき。

スキルのリンク

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/godot-4-migration/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/godot-4-migration/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“Godot 4で設定用の変数を宣言する方法を教えてください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

AIは古いGodot 3のコードと新しいGodot 4のルールを比較し、アニメーションや変数の宣言など、ゲームの特定の部分をどのように書き換えればよいかを例を示しながら説明します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Godot 4 Migration Guide

Overview

A critical guide for developers transitioning from Godot 3.x to Godot 4. This skill focuses on the major syntax changes in GDScript 2.0, the new Tween system, and export annotation updates.

When to Use This Skill

  • Use when porting a Godot 3 project to Godot 4.
  • Use when encountering syntax errors after upgrading.
  • Use when replacing deprecated nodes (like Tween node vs create_tween).
  • Use when updating export variables to @export annotations.

Migration procedure

Work in a backed-up branch or copy. Choose an exact Godot 4 version, validate conversion before changing files, and inspect converter gaps, renamed nodes, shaders, physics, plugins and export targets. Test scenes and saved games before replacing the working Godot 3 build. Examples below are fragments in an appropriate Node script; Enemy must be a declared project type.

Official guide: Upgrading to Godot 4.

Key Changes

1. Annotations (@)

Godot 4 uses @ for keywords that modify behavior.

  • export var x -> @export var x
  • onready var y -> @onready var y
  • tool -> @tool (at top of file)

2. Setters and Getters

Properties now define setters/getters inline.

Godot 3:

var health setget set_health, get_health

func set_health(value):
    health = value

Godot 4:

signal health_changed(health: int)

var health: int = 100:
    set(value):
        health = value
        emit_signal("health_changed", health)
    get:
        return health

3. Tween System

The Godot 3 Tween node was removed in Godot 4. Use create_tween() in code.

Godot 3:

$Tween.interpolate_property(...)
$Tween.start()

Godot 4:

var tween = create_tween()
tween.tween_property($Sprite, "position", Vector2(100, 100), 1.0)
tween.parallel().tween_property($Sprite, "modulate:a", 0.0, 1.0)

4. Signal Connections

String-based connections are discouraged. Use callables.

Godot 3:

connect("pressed", self, "_on_pressed")

Godot 4:

pressed.connect(_on_pressed)

Examples

Example 1: Typed Arrays

GDScript 2.0 supports typed arrays for type checking; measure performance rather than assuming a speedup.

# Godot 3
var enemies = []

# Godot 4
var enemies: Array[Node] = []

func _ready():
    for child in get_children():
        if child is Enemy:
            enemies.append(child)

Example 2: Awaiting Signals (Coroutines)

yield is replaced by await.

Godot 3:

yield(get_tree().create_timer(1.0), "timeout")

Godot 4:

await get_tree().create_timer(1.0).timeout

Best Practices

  • ✅ Do: Use @export_range, @export_file, etc., for better inspector UI.
  • ✅ Do: Type all variables (var x: int) for performance gains in GDScript 2.0.
  • ✅ Do: Use super() to call parent methods instead of .function_name().
  • ❌ Don't: Use string names for signals (emit_signal("name")) if you can use the signal object (name.emit()).

Troubleshooting

Problem: "Identifier 'Tween' is not a valid type." Solution: Godot 4 uses a Tween object returned by create_tween(), not a scene node or a SceneTreeTween type. Use var tween: Tween = create_tween() in a Node context.

Limitations

  • Use this skill only when the task clearly matches the scope described above.
  • Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
  • Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
よくある質問

「エクスポート」とは何ですか?

コードを変更せずに、Godotのツール上で直接設定できる変数のことです。Godot 4では「@export」を使います。

アニメーション(Tween)はどう変わりましたか?

Godot 3では「Tween」という名前のノードを使っていました。Godot 4では「create_tween()」を使って、コード上で直接アニメーションを作成します。

Godot 3の「yield」が動かなくなったのはなぜですか?

Godot 4では「yield」が「await」に置き換えられました。コード内の単語をその一方からもう一方に書き換える必要があります。

詳細

作者による元の説明

Specialized guide for migrating Godot 3.x projects to Godot 4 (GDScript 2.0), covering syntax changes, Tweens, and exports.

repo: sickn33/agentic-awesome-skills

人気

GitHubのスター
48k
ランキング
#4766
ライセンス
MIT
更新日
2026/10/15

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル