技能 godot-4-migration
🎮

godot-4-migration

安全

将 Godot 3 迁移到 Godot 4

升级 Godot 项目的游戏开发者会遇到语法错误和已弃用的功能。本技能提供了一份全面的指南,包含具体示例,帮助迁移 GDScript 2.0 代码。

支持: Claude Codex Code(CC)
📊 71 充足
1

下载技能 ZIP

2

在 Claude 中上传

前往 设置 → 功能 → 技能 → 上传技能

3

开启并开始使用

测试它

正在使用“godot-4-migration”。 将此 Godot 3 代码转换为 Godot 4:export var speed = 10

预期结果:

在 Godot 4 中,使用 @export 注解:

```gdscript
@export var speed: int = 10
```

你还可以添加类型提示和检查器提示:
```gdscript
@export_range(1, 100) var speed: int = 10
```

正在使用“godot-4-migration”。 如何在 Godot 4 中使用 Tweens?

预期结果:

Tween 节点已弃用。使用 create_tween() 方法:

```gdscript
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)
```

安全审计

安全
v1 • 2/25/2026

All static findings are false positives. The skill contains only documentation for Godot 4 migration with GDScript code examples. No shell commands, cryptographic code, or system reconnaissance present.

1
已扫描文件
127
分析行数
3
发现项
1
审计总数
中风险问题 (3)
False Positive: Shell Command Detection
Scanner flagged GDScript method calls like create_tween() and $Tween as shell commands. These are Godot game engine API calls, not system commands.
False Positive: Weak Cryptographic Algorithm
Scanner triggered on word 'deprecated' which contains character patterns matching crypto detection. No cryptographic code exists in this skill.
False Positive: System Reconnaissance
Scanner triggered on the word 'Problem:' in troubleshooting section. This is a documentation heading, not reconnaissance.
审计者: claude

质量评分

38
架构
100
可维护性
87
内容
50
社区
90
安全
83
规范符合性

你能构建什么

移植游戏项目

通过逐步语法指导,系统地将整个游戏项目从 Godot 3.x 升级到 Godot 4。

修复语法错误

在 Godot 4 中打开 Godot 3 项目时,快速解决编译错误。

学习 GDScript 2.0

了解 GDScript 2.0 中的新功能和模式,用于新的 Godot 4 开发。

试试这些提示

基本迁移帮助
如何在 Godot 4 中转换 @export var?展示旧语法和新语法。
Tween 系统迁移
将此 Godot 3 Tween 代码转换为 Godot 4:$Tween.interpolate_property($Sprite, 'position', Vector2(0,0), Vector2(100,100), 1.0, 0, 0)
信号连接更新
在 Godot 4 中如何使用 callables 连接信号,而不是使用 connect('signal_name', self, '_handler')?
完整项目评估
列出将 Godot 3 项目迁移到 Godot 4 所需的所有主要语法更改,并为每个类别提供示例。

最佳实践

  • 使用 @export_range、@export_file 和其他 @export 注解以获得更好的编辑器集成
  • 为 GDScript 2.0 中的性能提升,使用显式类型提示对所有变量进行类型标注
  • 使用 super() 调用父类方法,而不是旧的 .method_name() 语法

避免

  • 当可以使用信号对象的 name.emit() 时,不要使用 emit_signal('name')
  • 不要使用基于字符串的信号连接,如 connect('pressed', self, '_handler')
  • 不要在 Godot 4 中使用 yield() 进行协程 - 改用 await

常见问题

此技能会自动转换我的项目文件吗?
不,本技能提供指导和示例。实际转换必须手动完成或使用 Godot 的内置迁移工具。
我可以用这个技能迁移 C# 代码吗?
不,本技能仅涵盖 GDScript 语法。C# 迁移需要单独的考虑。
GDScript 1.0 和 2.0 之间的主要区别是什么?
GDScript 2.0 添加了类型提示、新注解系统(@export、@onready)、内联 setters/getters,并用 await 替换了 yield。
如何在 Godot 4 中处理 onready 变量?
使用 @onready 注解:@onready var sprite = $Sprite 代替 onready var sprite = $Sprite
Godot 4 中仍然可以使用 Tween 节点吗?
Tween 节点已弃用。在脚本中使用 create_tween() 方法以编程方式创建 Tweens。
我可以在 Godot 4 中使用 Godot 3 资源吗?
大多数资源可以工作,但有些可能需要更新。纹理和网格通常可以工作,但脚本必须迁移到 GDScript 2.0。

开发者详情

文件结构

📄 SKILL.md