What is the unit of distance in godot and can it be set to pixels?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By dbiton
:warning: Old Version Published before Godot 3 was released.

I noticed that the positions in godot 2D aren’t based on pixels (10,0 isnt 10 pixels far from 0,0), but on some arbitrary unit.

can godot be set so the unit of distance is in pixels? i.e, if i have an object moving in a speed of 20/second, it will move 20 pixels every second instead of 20 “units”, whatever they are.

If I understand right, the units are pixels, at least for the viewport.

You define a screen of 1280 pixels width, and something moving with a speed of 20 units/second (*delta) on x it should be around +(20,0) each second.

If the scaling deformed the screen reducing width at 640, it still will be 20 pixels/second for the game, while the screen will show 10.

eons | 2017-02-24 15:16

:bust_in_silhouette: Reply From: TomShar

yes you can work in pixels as your unit.

Features - Godot Engine See the 2D section: “Work in pixels as your units, but scale to any screen size and ratio.”

:bust_in_silhouette: Reply From: avencherus

It is in pixel units. How are you measuring it?

If you put the godot 64x64 project icon as a sprite that is non-centered, at position 0,0. Putting it’s top left corner at the origin.

Then add a position2D and move it to 64, 64. You should see it in the bottom right corner of the icon.

If your relative scale of everything is distorted, you may want to check your project settings to see what kind of stretch options you have for your display.