In 3D, how do I get global translation in instead of local?

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

I found Spatial.get_translation() which returns the local Vector3 position, and Spatial.get_global_transform() which returns the global Transform, but I can’t figure out how to parse the Transform to retrieve the global Vector3 position.

Thanks,
Michael

:bust_in_silhouette: Reply From: umfk

Isn’t that just Transform.origin?

Ah, there it is. Thank you!

CrazyM | 2016-03-02 18:57

No problem, I also had to look it up because I only knew about the 2D case. For reference I just looked for the Transform tutorial in the docs. Most of it talks about the 2D case but at the bottom there is some 3D information which mentions that in 3D origin and basis are separated instead of being packed into one 4x3 matrix.

umfk | 2016-03-02 19:40

Yeah, I see it in the Transform class member variables now. I had already looked there several times, but it just didn’t click. Thanks!

CrazyM | 2016-03-02 19:55

And for those who wants only the X, Y, Z… Just add .X,Y or Z on the end of the code: Like:

transform.origin.x

S4_Yuuki | 2022-02-09 00:34