World 1-1 The Fundamentals : GDScript intro

Part 7: Printing & Debugging in GDScript

Learn how to use the print() function in GDScript to debug your code, track execution, and avoid flooding the Godot console.

Writing Your First Line of GDScript

So far we’ve set up a script and explored its structure. Now it’s time to actually write some code!

In this part of my journey, I experimented with two common functions in Godot: _ready() and _process(delta). I wanted to understand how and when they run—so I did what every beginner coder does: printed "Hello, world!".

🧪 The First Print

Inside the _ready() function, I wrote:

gdscript
1
2
3
4

func _ready():
    print("Hello, world!")

This function runs once when the scene is loaded. So when I hit Play, the console printed "Hello, world!" exactly one time. Super simple—but super satisfying!

Godot console output

🔁 The Update Loop

Next, I used _process(delta) to print a message on every frame. Here’s what I added:

gdscript
1
2
3
4

func _process(delta):
    print("Refreshing...")

When I ran the game again, the console filled up with “Refreshing…” messages, printing nonstop every frame until I paused or stopped the game.

This was my first real glimpse into the game loop—where things like movement and animation will eventually go.

Godot console output

💡 What I Learned

  • _ready() is perfect for setup code—it runs once when the node is added to the scene.
  • _process(delta) is called every frame and is great for logic that needs to repeat.
  • print() helps me see what’s running and when.
  • Debugging output shows up in the bottom console in Godot.

This small experiment helped me see how code hooks into the engine’s update cycle. Even though I didn’t build anything fancy yet, just understanding how and when functions run made everything feel a little less like magic.


SightlessDev