Mr Laliberte

Position & Movement in GDScript

Game Development with Godot · Variables and Data · Lesson 3

Courses › Game Development with Godot › Position & Movement in GDScript

The Screen Is a Grid

Every 2D object in Godot lives somewhere on a grid of x and y coordinates. The top-left corner of the screen is (0, 0).

(0, 0)
top-left
x increases → (max x, 0)
top-right
y increases ↓ center of screen
(0, max y)
bottom-left
(max x, max y)
bottom-right

The position Variable

Every 2D object automatically has a built-in variable called position, made of two parts:

Part Controls
position.x How far right the object is (bigger = further right)
position.y How far down the object is (bigger = further down)

Setting a Position

You can move an object instantly by setting its position in _ready():

func _ready():
    position.x = 300
    position.y = 150

Run this, and the object jumps straight to that spot the moment the game starts — it won’t move again on its own after that.

Repeating Instructions: _process(delta)

Remember from Week 1: _ready() runs ONCE, but _process(delta) runs OVER AND OVER, many times every second. That makes it perfect for movement.

delta is a special value: the amount of time that passed since the last frame. Multiplying by delta means “move this much per second” instead of “move this much per frame”, which keeps movement speed consistent no matter how fast or slow the computer is running.

Making Something Move

Combine position and _process(delta) to create real movement:

func _process(delta):
    position.x += 100 * delta

This line runs many times per second, nudging the object a little further right each time — which looks like smooth motion.

Direction & Speed

Change This Effect
Bigger number (e.g. 100 → 300) Object moves faster
Smaller number (e.g. 100 → 20) Object moves slower
Negative number (e.g. 100 → -100) Object moves in the opposite direction
Use position.y instead of position.x Object moves up/down instead of left/right

Quick Reference Card

SymbolMeaning
position.xleft/right location
position.yup/down location
_ready()runs once, at the start
_process(delta)runs every frame, over and over
deltatime since the last frame
position.x += speed * deltamoves right over time
position.x -= speed * deltamoves left over time

Welcome back