Print in Godot
Part of the Nodes and Scenes section of Coddy's Godot journey. Lesson 3 of 28.
print() can take several values, separated by commas. It writes them on one line, with nothing in between:
print("Lives: ", 3)That prints Lives: 3. The space after the colon is inside the quotes, so it is printed too.
position is where a node stands. Printing it shows two numbers, how far right and how far down:
print(position)For the robot this prints (320.0, 180.0). Printing values shows you what your game is doing.
Challenge
EasyMake the robot say where it stands.
- In
_ready(), giveprint("I am at ")a second value after a comma:position. - Use
positionitself, not the numbers.
Press Play: the Console shows I am at (320.0, 180.0). Then Check.
Try it yourself
extends Node2D
func _ready():
print("I am at ")
All lessons in Nodes and Scenes
1Your First Godot Game
What Is Godot?Ready Runs OncePrint in GodotThe Scene TreeSet a PositionMove a Node OncePractice on your own: Godot playground