This hereâs a machine-translated text that might contain some errors!
Where does this information come from?
A whole heap of this is just a retelling of Godotâs official documentation. Down below youâll find some useful links to the official documentation (which I reckon you oughta use over this here on Piggy, but if you prefer this one, go right ahead!)
Useful resources:
What about graphics, do I gotta make âem myself?
Nope! Yâall can find a heap oâ free stuff right here:
Other Useful Links:
Other game engines?
If ya prefer, ya can use other game engines. Examples of other game engines be:
Thereâs plenty more out there, so feel free to scout âem out if ya wanna try somethinâ else!
What in Tarnation is Godot?
Godot (Pronounced Guh-doh), is a âGame Engineâ. To put it plain and simple, itâs a program that lets ya make games (or regular programs if ya feel like it). Godot can do most anything other game engines can do, both 2D and 3D.
Examples of games made in Godot: Godot Showcase
It ainât just Indie games thatâve been made in Godot, Sonic Colors Ultimate was made with Godot! đŠđŠđŠ
How Do Ya Get Yer Hands on Godot?
Ya can either download Godot from:
- The official site: Godot Official Page.
- Or on Steam: Godot Steam.
Just download âer and install (or run âer on Steam).
Set Up a Project!
When you start Godot, you get this window:
Here youâre asked about programming language, GDScript or C#. GDScript is mighty similar to Python.
Differences between GDScript and Python (without colors):
def hello():
text = "Hello world!"
print(text)
func hello():
var text = "Hello world!"
print(text)
For variables in Python, you just gotta write the name of the variable. In GDScript, you gotta write var first. To make functions, you write func instead of def.
Scenes & Nodes
One oâ the most important concepts within Godot is Scenes and Nodes. We can start with nodes. A node is an object in Godot, and it can represent just âbout anything. It can be somethinâ representinâ a player, an enemy, a button in a menu, text on the screen, all sorts oâ things. Scenes are a collection oâ nodes.
Here weâre gonna make a real simple example.
Part 1a - Set Up the âplayerâ Scene
At the top of the Godot window, press the â2Dâ button to change the view to a 2D view.
On the left side of the window, youâll see the following interface:
Press the âOther Nodeâ button, and search for âCharacterBody2Dâ, select it and press âCreateâ. This hereâs a node used for a 2D player. You might notice a warninâ triangle â ïž next to the âCharacterBody2Dâ node. Thatâs âcause itâs missinâ a few things itâd like to have.
If you right-click on the node thereâs a â+ Add Child NodeâŠâ button. Use that and add two nodes, Sprite2D and CollisionShape2D. Sprite2D is used to add some graphics to the player, while the other oneâs used to check for collisions. You can also give âem names if it makes it easier to keep track of things. Iâve given my CharacterBody2D the name âPlayerâ. Your scene should look like this now:
Part 1b - Fixinâ â ïž on CollisionShape2D
The warninâ triangle in this here case is that the CollisionShape2D is missinâ actual collision. You can fix this by clickinâ on the node (on the left), then a panelâll pop up on the right side. Here you get a whole mess oâ information âbout the node you can change. Feel free to mess around with whatâs there. But the one we wanna focus on is âShapeâ, set this to somethinâ like RectangleShape2D. It ainât all that important, we ainât gonna be usinâ the collisions here.
Part 1c - Addinâ a Sprite, Graphics
If ya click on Sprite2D on the left, itâll bring up the fields on the right, where it says âTextureâ. Here ya can put in a picture for the player. Just drag a picture in and drop it in the field.
Hereâs what itâll look like after addinâ a sprite.
Part 2 - Addinâ Input, Controls
At the top oâ the window, thereâs a menu, âScene - Project - Debug - Editor - Helpâ. Press on âProjectâ and then âProject Settingsâ. Here ya get a menu with a whole heap oâ settings. Press on âInput Mapâ. Here ya can set up buttons on the keyboard.
- In the âAdd New Actionâ field, write âleftâ then press âAddâ.
- Then add ârightâ, âupâ and âdownâ.
- These here are known as âActionsâ
- On each âActionâ ya can add buttons by pressinâ the + button to the right.
- Here ya just gotta press on the keyboard, then press Add.
- Add buttons on all actions.
Part 3 - Addinâ a Script to Control the Player.
To be able to add game logic, meaninâ do somethinâ with the player, the background, or whatever it might be in the game, we need a script. Scripts are code, and can be written in two languages, GDScript or C#, GDScript is the default.
- Press on the âCharacterBody2Dâ node (I done called it âPlayerâ).
- Press on the âAttach Scriptâ button (see below)
- Here ya get a window where ya can choose a language (choose GDScript) and a path (just leave it as it is, but ya can give it a name), then press on further. Here ya get a âScriptâ window. Ainât much here to start with.
extends CharacterBody2D
# Dette er hovedskriptet for spilleren.
# This here's the main script fer the player.
# Her defineres spillerens bevegelse og handlinger.
# Here's where we define how the player moves 'n' what they do.
var speed = 200
# Hastighet spilleren beveger seg med.
# How fast the player moves, ya see.
func _physics_process(delta):
# Beveg spilleren basert pÄ input.
# Move the player 'round based on what ya press.
var direction = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
velocity = direction * speed
move_and_slide()
The only thang this here codeâs sayinâ right now is that the codeâs gotta belong to a node of the âCharacterBody2Dâ type, which is our player.
Weâre gonna add a function here that weâre gonna use to wrangle the player:
extends CharacterBody2D
# Dette er en tom funksjon.
# This here is a empty function.
func _physics_process(delta: float) -> void:
return
Physics Process?
_physics_process is a function that gets updated every single âframeâ, meaninâ âround 60 times a second (default). Thereâs another function just called _process, which updates all the time. If ya want yer player movinâ at a steady pace, ya use _physics_process.
Right hereâs where weâre gonna put the code that moves the player âround.
Part 4 - Basic Input
In Part 2, ya added input buttons, now weâre gonna use âem. Thereâs a built-in object called Input that we can use to check if the playerâs pressed what weâve set up in the âInput Mapâ.
Try addinâ this here code into yer _physics_process code:
if Input.is_action_pressed('right'):
velocity.x = 100
move_and_slide()
What is move_and_slide()?
move_and_slide() is a built-in function in Godot thatâs used when we actually want to move whatever weâre applyinâ it to. Without this here function, the player ainât gonna be movinâ a muscle.
Warning
The spacing on the lines is mighty important, this here is the same as in Python.
What happens when ya start the program by pressinâ the play button in the Godot window, then pressinâ ârightâ?
If nothinâ happens now:
- Did ya remember to set somethinâ up in the âInput Mapâ?
- Did ya write
rightand notRight? Meaninâ, is what ya wrote in the code the same as the name in the input map?
All the code so far
extends CharacterBody2D
func _physics_process(delta: float) -> void:
if Input.is_action_pressed('right'):
velocity.x = 100
move_and_slide()
Now try addinâ some code for 'left', 'up', and 'down'.
Whatâs velocity.x gotta be for left? How âbout up and down?
The whole dang code now
extends CharacterBody2D
func _physics_process(delta: float) -> void:
if Input.is_action_pressed('right'):
velocity.x = 100
if Input.is_action_pressed('left'):
velocity.x = -100
if Input.is_action_pressed('down'):
velocity.y = 100
if Input.is_action_pressed('up'):
velocity.y = -100
move_and_slide()
Part 5 - Fixinâ the Code
Now, ya might notice the player donât stop when ya let go of a direction. We can fix that right now!
Before all them if statements, add a line that sets velocity to 0. Ya can do that by writinâ velocity = Vector2()
All speeds and directions in Godot are vectors, this hereâs a math concept we ainât gonna get into right now, but if yaâre wonderinâ more âbout what that means, ya can mosey on over here: Wikipedia vectors.
The whole dang code right now
extends CharacterBody2D
func _physics_process(delta: float) -> void:
velocity = Vector2()
if Input.is_action_pressed('right'):
velocity.x = 100
if Input.is_action_pressed('left'):
velocity.x = -100
if Input.is_action_pressed('down'):
velocity.y = 100
if Input.is_action_pressed('up'):
velocity.y = -100
move_and_slide()
When ya start the game now, ya can move the player around:
Further, yaâll can fix the code to make the speed not just be a number, but can be stored somewhere else.
Ya can, fer instance (before the function) add a constant that keeps track of the speed.
The whole dang code at the end with const
extends CharacterBody2D
const SPEED = 100
func _physics_process(delta: float) -> void:
velovity = Vector2()
if Input.is_action_pressed('right'):
velocity.x = SPEED
if Input.is_action_pressed('left'):
velocity.x = -SPEED
if Input.is_action_pressed('down'):
velocity.y = SPEED
if Input.is_action_pressed('up'):
velocity.y = -SPEED
move_and_slide()
Part 6 - Go On and Play Around!
If yâall head back to the first part, Useful Resources, you can find what you can continue to play with.
After this, you can try makinâ yer own game. What you build is up to you! If you wanna make somethinâ brand new, go right ahead! If you wanna try copyinâ a game that already exists, do that too! Best way to learn is by tryinâ!




