GDScript for Kotlin Developers
Move from Kotlin to Godot 4 GDScript through 48 multi-file tasks: typing, collections, script classes, callables, signals and failure contracts. Build a connected stock depot and port two Kotlin programs.
Kotlin and GDScript side by side
The same program in Kotlin and in GDScript, from the lessons of this course.
Text and Comments
Kotlin println accepts one value, so use a string template or other formatting before printing multiple values. GDScript print accepts several arguments and concatenates them without adding spaces. Kotlin starts at main, while this Godot runner invokes a Node…
Kotlin1 2fun main() { println("tag ${7}"); println("# data") }GDScript1extends Node2 3func _ready() -> void:4 print("tag", 7)5 print("# data")Branches and Values
Kotlin if is an expression that can produce a value; it does not need a separate ternary operator. GDScript if is a statement, while its conditional expression places the true value before the condition. Both execute only the selected branch. Ordered branch…
Kotlin1 2fun main() { val n=-2; println(if(n<0) "west" else "east") }GDScript1extends Node2 3func _ready() -> void:4 var n: int = -25 print("west" if n < 0 else "east")Array Operations
Kotlin MutableList exposes add and remove operations, while List offers a read-only interface that does not itself guarantee deep immutability. GDScript Array is mutable unless explicitly made read-only. Its negative indices count from the end, unlike…
Kotlin1 2fun main() { val items=mutableListOf(3); items.add(8); val removed=items.removeAt(items.lastIndex); println("$removed ${items.size}") }GDScript1extends Node2 3func _ready() -> void:4 var items: Array = [3]5 items.append(8)6 var removed = items.pop_back()7 print("%d %d" % [removed,items.size()])String Operations
Kotlin Strings are immutable, and literal replace returns a new String while replacing matching occurrences. GDScript String.replace likewise returns a result rather than rebinding the original. Kotlin Regex replacement has a separate interpretation, so…
Kotlin1 2fun main() { val s="a-b-a"; val t=s.replace("-","/"); println("$s $t") }GDScript1extends Node2 3func _ready() -> void:4 var s: String = "a-b-a"5 var t: String = s.replace("-","/")6 print(s," ",t)Scripts as Classes
Kotlin files can declare top-level functions and multiple classes. A GDScript file is itself a script class; class_name registers a global name and extends selects its base. Ordinary class-instance assignment shares references in both languages. RefCounted…
Kotlin1class Token { var text="blue" }GDScript1class_name DemoToken2extends RefCounted3var text: String = "blue"Inheritance and Super
Kotlin classes and members are final by default; mark them open for inheritance and override specialization. GDScript extends one direct superclass and permits ordinary instance overrides without Kotlin open declarations. Both use super to call inherited…
Kotlin1open class Base { open fun label():String="base" }GDScript1class_name DemoBase2extends RefCounted3func label() -> String:4 return "base"
Syllabus
10 chapters48 lessons1 project48 challenges99 quiz questionsScripts and Scalar Values
6 lessonsFlow and Functions
6 lessonsCollection Ownership
6 lessonsText and Callable Values
3 lessonsObjects and State
5 lessonsObject Relationships
5 lessonsEvents and Failure
5 lessonsBoundaries and Lifetimes
6 lessonsConnected Stock Depot
Project4 lessonsFinal Ports
2 lessonsFrequently asked questions
Who is GDScript for Kotlin Developers for?
For people who already write Kotlin and want to learn GDScript. Each lesson starts from Kotlin you know and shows how GDScript does the same thing, so you skip the beginner basics.
Do I need to know GDScript already?
No. The course starts with your first GDScript program. You need Kotlin basics: variables, conditions, loops, functions and collections.
How many lessons does GDScript for Kotlin Developers have?
GDScript for Kotlin Developers contains 48 interactive lessons you can complete at your own pace.
What does GDScript for Kotlin Developers cover?
The course is organized into chapters covering: Scripts and Scalar Values, Flow and Functions, Collection Ownership, Text and Callable Values, and more.
Is GDScript for Kotlin Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.