Your first Kotlin class
Let's create a first class that prints a simple hello world message when the node enters the scene tree.
Create src/main/kotlin/com/yourcompany/game/Player.kt with:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
Create src/main/java/com/yourcompany/game/Player.java with:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
Create src/main/scala/com/yourcompany/game/Player.scala with:
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
This small example already shows the main building blocks:
@RegisterClassmakes the class visible to Godot.@RegisterFunctionexposes_ready()to Godot.GD.print(...)writes to the Godot output.
The signals and callables guide is a good next step once you have this basic class working.
Now trigger a build:
1 | |
Once the build completes, you will be able to use your class in Godot. Simply attach the generated gdj file (by default, generated in the gdj/ directory at the root of the project; for more details, read the user guide) to a node like you would in GDScript. If you rebuild the project while the editor is open, your classes will be reloaded automatically in Godot and you can use them.

Info
As the JVM languages are compiled, you can only use newly created classes after you have built them. Otherwise, Godot will not be able to find them.
Final project structure
Depending on the language you picked, the final project should include one of these source roots:
1 2 3 4 5 6 7 | |
1 2 3 4 5 6 7 | |
1 2 3 4 5 6 7 | |