Scale is stored in the magnitude of each Vector3 in each of the Vector3s in the Basis, at least that is what I have observed. So, to get the scale, you need to do something like this:
var object_scale = Vector3(
global_transform.basis.x.length(),
global_transform.basis.y.length(),
global_transform.basis.z.length())
Edit: After looking at the documentation, I found the get_scale
method in Basis, which should do the same thing. :smile:
I'm not 100% sure if it will work, but if you want to convert a position from local/object space to global space, with the proper rotation, position, and scale adjustments applied, you can use global_transform.xform(position)
or global_transform.xform_inv(position)
. I forget which one does what, but they convert from local/object space to world space, applying all of the changes in position, scale, rotation, etc.
I've used both functions in my Inverse Kinematics scripts, both the old FABRIK and the new one I'm working on, and it works great for converting. It might be something to look into if you have not tried it.