Coordinate System

From Augmotic Library

Overview

When working in 2D or 3D mediums, the Coordinate System is a core feature that will dictate and influence your workflow and the mathematics behind many operations. Learning and committing it to memory is crucial to preventing mishaps and future struggles.

It has sparked controversy and religious wars since the dawn of humanity, and everyone has their own opinion of the "correct" way to implement them. Unfortunately, this leads to multiple flavors across different tools and software.

Unreal Engine is not exempt from the turmoil of competing standards, boasting a uniquely flavored iteration compared to similar engines and frameworks.

Spaces

Unreal Engine uses a Left-Handed, Z-Up Cartesian Coordinate System for its world and local spaces.

The direction, plane, and color stay consistent throughout the Engine. X+ is Forward, Y+ is Right, and Z+ is Up.

However, the frame of reference or "space" used when working with objects will dictate how these coordinates are calculated. There are two spaces that the object can reference: World Space and Local Space.

World Space

Position and direction are referenced to the level's origin.

This means any movement and rotation calculations will be based on the level. Moving 100 units forward will be in the same direction regardless of the rotation or position of an object. Setting an object's world position to (0,0,0) will take it to the level's origin.

Most blueprint and native functions use world space as their reference. However, there are some exceptions. Reading the documentation to ensure a function is working in the expected space is essential.

World Based Nodes: Set World Location, Get Actor Forward Vector, Get Actor Transform

Local (Relative) Space

Position and direction are referenced to the object's parent.

This means any movement and rotation calculations will be based on the rotation and position of the reference frame. Moving 100 units forward will offset based on the parent. Setting an object's local position to (0,0,0) will take it to the parent's origin.

There are a few functions that are based on the local space. These are usually used for components.

Local Based Nodes: Set Actor Relative Location, Get Actor Relative Transform

Transform Gizmo

Axis Direction Color
X Forward Red
Y Right Green
Z Up Blue

The Transform Gizmo and viewport bar are helpful tools to determine the direction and space of an object.

It can switch between World and Local coordinate systems and is indicated by a button in the top right of the viewport. The shortcut (Ctrl + `) can also be used.

Debugging

If a visualization is needed during runtime debugging, a Transform indicator can be drawn using the Draw Debug Coordinate System node.


Examples

World vs Local Forward

The world cube has a drawn coordinate system using world forward, while the local uses the cube's forward.