Forward Direction
2025/12/27
- Type
- Learning Resource
- Format
- Glossary Article
- Version
- General
- Subject Tags
- Created
- Updated
- 2026/02/16
- 2025/12/27
In computer graphics, elements' position, scale, and rotation are defined in a local coordinate system. This is often called a "transform" or "basis" in 3D.
A local coordinate system is a system that moves with you. For example, your left and right sides are always the same, no matter which direction you're facing. North, south, east, and west are a global coordinate system, while left, right, front, and back are your local coordinate system.
The forward direction is the direction in which an object is facing. This is often used to move an object in the direction it is facing, without having to know its angle.
For example, to move a bullet in the direction it is facing in 2D, you can use the following code:
var speed := 1000.0
func _physics_process(delta: float) -> void:
position += transform.x * speed * deltaWith this, you only need to orient the bullet once, and it will then move in that direction forever. By convention, transform.x is the forward direction in 2D (at least if you draw assets to face right by default).
In 3D, in Godot, the forward direction is the basis.z vector by convention. Here's an example of how to move an object in the direction it is facing in 3D, assuming the 3D model faces forward along the Z axis:
var speed := 10.0
func _physics_process(delta: float) -> void:
var motion := basis.z * speed * deltaDon't stop here. Step-by-step tutorials are fun but they only take you so far.
Try one of our proven study programs to become an independent Gamedev truly capable of realizing the games you’ve always wanted to make.
Get help from peers and pros on GDQuest's Discord server!
20,000 membersJoin ServerThere are multiple ways you can join our effort to create free and open source gamedev resources that are accessible to everyone!
Sponsor this library by learning gamedev with us onGDSchool
Learn MoreImprove and build on assets or suggest edits onGithub
Contributeshare this page and talk about GDQUest onRedditYoutubeTwitter…