How to get a local transformation?

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

Hey.
There is a global transformation 1.
There is a global transformation 2.
How to get a local transformation 1 relative to 2?
(Assuming that the transformation of 2 will be the beginning of the beginning)
p.s. 3D

:bust_in_silhouette: Reply From: Zylann

I think it’s by undoing the second transform on the first one:

local = global2.xform_inv(global1) ?

var aa_transf = get_node('aa').get_global_transform()
var bb_transf = get_node('bb').get_global_transform()
var transf = bb_transf.xform_inv(aa_transf)
print(transf)

Console for some reason displays “Null”

p.s. Godot 3.0 Alpha1

Tort | 2017-08-15 15:56

Aaaah ok for some reason this function cannot take a Transform, it can take a Vector3, a Rect3 or a Plane.

Try this instead then, same idea, written differently:

local = global2.affine_inverse() * global1

Zylann | 2017-08-15 20:47

Zylann, thanks!

Tort | 2017-08-15 22:13