godot-4-migration
Skill này làm gì
Hướng dẫn này giúp bạn cập nhật trò chơi làm bằng Godot 3 lên Godot 4. Nó giải thích những thay đổi trong cách viết code (GDScript 2.0), cách dùng hoạt ảnh (Tween) và cách khai báo biến xuất hiện trong phần cài đặt trò chơi (export).
Khi nào nên dùng
- ✓Khi bạn đang cập nhật trò chơi từ Godot 3 lên Godot 4.
- ✓Khi code của trò chơi ngừng hoạt động sau khi cập nhật.
- ✓Khi bạn cần thay đổi cách hoạt ảnh hoạt động.
Liên kết skill
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/godot-4-migration/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Làm thế nào để khai báo lại các biến cấu hình trong Godot 4?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
AI so sánh code cũ của Godot 3 với quy tắc mới của Godot 4, đưa ra ví dụ về cách viết lại những phần cụ thể của trò chơi, như hoạt ảnh và khai báo biến.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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
Tweennode vscreate_tween). - Use when updating
exportvariables to@exportannotations.
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 xonready var y->@onready var ytool->@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.
Câu hỏi thường gặp
“Export” là gì?
Đây là các biến bạn có thể cấu hình trực tiếp trong công cụ của Godot mà không cần sửa code. Trong Godot 4, chúng được khai báo bằng '@export'.
Hoạt ảnh (Tween) đã thay đổi thế nào?
Trong Godot 3, bạn dùng một node tên là 'Tween'. Trong Godot 4, bạn tạo hoạt ảnh trực tiếp trong code bằng 'create_tween()'.
Tại sao code có 'yield' của tôi không còn chạy?
'yield' đã được thay bằng 'await' trong Godot 4. Bạn chỉ cần đổi từ này sang từ kia trong code.
Chi tiết
Mô tả gốc của tác giả
Specialized guide for migrating Godot 3.x projects to Godot 4 (GDScript 2.0), covering syntax changes, Tweens, and exports.
Độ phổ biến
- Sao GitHub
- 48k
- Vị trí xếp hạng
- #4766
- Giấy phép
- MIT
- Cập nhật
- 15/10/2026
Bình luận
- …
Thêm skill từ kho mã này
00-andruia-consultant
48kGiúp agent của bạn bắt đầu hoặc cải thiện các dự án AI. Phân tích mã, gợi ý công cụ và lập kế hoạch hành động bằng tiếng Tây Ban Nha.
007
48kCho phép agent của bạn thực hiện kiểm toán bảo mật và mô hình hóa mối đe dọa. Hữu ích để bảo vệ dự án khỏi các cuộc tấn công và lỗ hổng.
10-andruia-skill-smith
48kGiúp agent của bạn tạo hoặc cải thiện các công cụ AI. Xác định cách công cụ hoạt động, viết tài liệu và kiểm tra cấu trúc.
20-andruia-niche-intelligence
48kGiúp agent của bạn tạo bản tóm tắt về một ngành cụ thể. Hữu ích để hiểu bối cảnh, quy tắc, cách người dùng tương tác và rủi ro của dự án.
Skill tương tự
diffs
394kGiúp agent của bạn tạo một diff có thể chia sẻ về các chỉnh sửa, dưới dạng liên kết xem hoặc file ảnh, thay vì một bản tóm tắt viết tay.
coding-agent
394kGiúp agent của bạn giao một việc lập trình lớn cho Codex, Claude Code hoặc OpenCode chạy nền, rồi theo dõi tiến độ của nó.
gh-issues
394kGiúp agent của bạn tìm issue trên GitHub, chọn những issue cần xử lý và mở pull request với bản sửa, kể cả theo dõi nhận xét đánh giá.