Migrate Godot Projects to Version 4
A migration guide for developers porting Godot 3.x projects to Godot 4, covering GDScript 2.0 syntax changes, the new Tween system, and export annotations.
Why it matters
Streamline your transition from Godot 3.x to Godot 4 with this comprehensive migration guide. It covers essential syntax changes, new systems, and best practices to ensure a smooth upgrade process for your game development projects.
Outcomes
What it gets done
Update GDScript 2.0 syntax and annotations.
Implement the new `create_tween()` system.
Refactor signal connections to use callables.
Adapt to changes in export variables and property setters/getters.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/ag-godot-4-migration | bash Overview
Godot 4 Migration Guide
A migration guide covering GDScript 2.0 syntax changes, the new Tween system, and export annotations for developers moving from Godot 3.x to Godot 4. Use when porting Godot 3 projects to Godot 4, encountering syntax errors after upgrading, replacing deprecated nodes, or updating export variables to @export annotations.
What it does
This skill provides a guide for developers transitioning from Godot 3.x to Godot 4. It covers major syntax changes in GDScript 2.0, including the new annotation system, the replacement of the Tween node with create_tween(), and updated property syntax for setters and getters.
When to use - and when NOT to
Use this skill when porting a Godot 3 project to Godot 4, when encountering syntax errors after upgrading, when replacing deprecated nodes like the Tween node, or when updating export variables to @export annotations.
Do not use this skill for tasks outside the migration 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.
Inputs and outputs
You provide questions or code snippets related to Godot 3.x to Godot 4 migration. You receive syntax updates and code examples showing before-and-after patterns.
Key migration patterns
Annotations now use the @ prefix. In Godot 3, you wrote export var x, but in Godot 4 you write @export var x. Similarly, onready var y becomes @onready var y, and tool becomes @tool at the top of your file.
Setters and getters are now defined inline:
var health: int:
set(value):
health = value
emit_signal("health_changed", health)
get:
return health
The Tween node is deprecated. Instead of $Tween.interpolate_property(...) and $Tween.start(), use:
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)
Signal connections now use callables instead of strings. Replace connect("pressed", self, "_on_pressed") with pressed.connect(_on_pressed).
Coroutines use await instead of yield:
await get_tree().create_timer(1.0).timeout
GDScript 2.0 supports typed arrays:
# Godot 3
var enemies = []
# Godot 4
var enemies: Array[Node] = []
func _ready():
for child in get_children():
if child is Enemy:
enemies.append(child)
Best practices
Type all variables (var x: int) for performance gains in GDScript 2.0. Use @export_range, @export_file, and similar annotations for better inspector UI. Use super() to call parent methods instead of .function_name(). Prefer signal objects (name.emit()) over string-based emission (emit_signal("name")).
Troubleshooting
If you encounter "Identifier 'Tween' is not a valid type," note that Tween is now SceneTreeTween or just an object returned by create_tween(). You rarely type it explicitly, just use var tween = create_tween().
Who it's for
This skill is for developers transitioning from Godot 3.x to Godot 4.
Source README
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.
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.