Variables
- @export = shows in Inspector (like [SerializeField])
- Type inference with := (optional but recommended)
Compare familiar Unity C# patterns against concise Godot 4 GDScript equivalents. Pick a topic, scan the differences, then copy the Godot version into your own scene script.
You are turning a tuned Unity or Unreal component into a Godot script that designers can still adjust in the Inspector.
Godot exports variables from the script that owns the node. The important shift is deciding what belongs as editable data and what should stay internal state.
public float speed = 5.0f;
private int health = 100;
[SerializeField]
private GameObject target;
[SerializeField]
private Sprite[] sprites;var speed := 5.0
var health := 100
@export var target: Node
@export var sprites: Array[Texture2D]_ready() = Start() / BeginPlay()_process(delta) = Update() / Tick()extends Node = : MonoBehaviour@export var = [SerializeField]$NodePath = GetComponent / FindChildqueue_free() = Destroy()Most of the translation is mechanical once three habits change. First, there is no
component lookup: a script is the node it sits on, and child nodes are
reached with $Path or get_node(). Second, lifecycle and
event plumbing move to _ready(), _process(delta), and
signals, so there are no delegates or UnityEvents to wire in the Inspector. Third,
types are optional but worth writing: var speed := 5.0 and func hit(damage: int) -> void give you autocompletion and catch the
same mistakes the C# compiler would. Each topic below lists the differences the lab
highlights; open one to see the full side-by-side code.