Following a Godot tutorial I encountered the transform property, but I'm not sure what it means nor how to use it.

I read the official Godot documentation, but it didn't give me a full explanation about the theme. I just got this:

Transform2D transform

Setter set_transform(value)

Getter get_transform()

Could someone explain to me more about this?

  • 1
    \$\begingroup\$ @DMGregory gave a pretty good answer, but I'll add that the godot docs do discuss Transforms \$\endgroup\$
    – rcorre
    Nov 16, 2019 at 21:01

1 Answer 1


In games, a "transform" refers to how an object is positioned, oriented, or scaled within the game world.

To move an object, to rotate an object, or to squash and stretch an object are all forms of "transformation". The transform is a data structure that stores the current transformation state of the object: where it is, which way it's facing, and how big it is.

Frequently games use a "transformation hierarchy" - meaning that objects are organized into nested relationships of "parent" objects that contain "child" objects, arranged so that if you transform the parent, all of its children and grandchildren etc. get transformed together with it.

In this context, an object has two transforms: its local transform relative to its parent node, and a global transform representing its ultimate position/orientation/scale in the world after factoring in all the effects of its parent, grandparent, etc.

In Godot, Node2D.transform is the local transform. It offers members like...

  • get_origin(): where should this node sit, relative to its parent's origin and rotation?

  • get_rotation(): how is this node rotated relative to its parent (in radians)?

  • get_scale(): how has this node been squashed or stretched relative to its parent's scale?

Another way to think of transformation is to think of "local space". As I sit at my desk, I am facing southward. If I extend my right arm out to the side, it represents my "local x+ axis", currently pointing west. If I turn 90 degrees to my right, my right arm now points north. So I carry my own local coordinate system with me as I move and orient myself in space.

Game objects do this too. A Godot transform gives you vectors representing the direction that the object's local x+ axis and local y+ axis point, within its parent's local space. Its parent's space in turn can be transformed relative to the grandparent's local space, all the way up to the global coordinate system.

There is also a Node2D.global_transform representing the object's net transformation in the world, after its parent, grandparent, etc.'s local transforms have all been stacked-on.

Under the hood, a transform might be stored as a transformation matrix, or as a position vector, a rotation angle / quaternion, and a scale touple.

  • \$\begingroup\$ Thank you for answering. I never tought it was this way but now I could use this better. Thank you :D \$\endgroup\$ Nov 16, 2019 at 23:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .