Godot-docs: Need an actual example for global to local space transform

Created on 5 Nov 2016  路  2Comments  路  Source: godotengine/godot-docs

Hello,

I just tried and successed to transform a position that was in world/global coordinates (from get_collider_point()) into object/local coordinates for one of my object.

I did not find the documentation straight away from a google search.
I needed to walk through the doc for some time before to realize that this part on matrices was trying to answer my question:
http://docs.godotengine.org/en/stable/tutorials/matrices_and_transforms.html

However, I found it a bit confusing as it is not clearly say that is about local/global or world/object coordinates.
At first, I thought that Matrix32 were a bit mysterious and I didn't see how to get them.
Unfortunately, there is no actual example!

I finally understood that the Matix32 of an object was given by the get_transform() function, and so I only needed to do:
var local_pos = get_transform().xform_inv(collision_point)

That is quite practical. But maybe that part of the doc could quickly mention a true world example with get_transform() ?
Alternatively, we could have a convenience function that transform from local to global and from global to local?

Most helpful comment

now there are to_local and to_global methods which are used for that purpose

All 2 comments

Convenience functions would be lovely but this part of the docs really needs an update.

I was stuck for the longest time on converting local to global and back.

now there are to_local and to_global methods which are used for that purpose

Was this page helpful?
0 / 5 - 0 ratings

Related issues

youreperfect picture youreperfect  路  3Comments

RiverMesa picture RiverMesa  路  4Comments

clayjohn picture clayjohn  路  4Comments

tavurth picture tavurth  路  3Comments

creikey picture creikey  路  4Comments