On a spatial node calling `get_global_transform().basis.get_scale()` and `scale` both return the same values regardless of the global rotation of the node. I want to be able to scale a node by a specific amount along a global axis even if it has been rotated. How do a find a Spatial's scale values in global XYZ so I can do this?

Thank you!!

Godot version 3.3
in Engine

Here is how I solved this for anyone who may find this in the future.

``````# scales the Spatial by the amount in the given global direction
func scaleDirection(amount: Vector3, camRot: Vector3):

var selfQuat = transform.basis.get_rotation_quat()  # get the global rotation
var sclXform = Transform(selfQuat) # make it a transform so we can apply it to a vector

var globalScale = sclXform.xform(scale) # convert local scale to scale on global axis'
globalScale = globalScale.abs() # scale should always be positive but rotation can make it negative when converted to global

# when camera is behind the object axis direction must be inverted:
if(camRot.y < 0):
amount.x = -amount.x
pass
if(camRot.y > 90 or camRot.y < -90):
amount.z = -amount.z
pass

# calculate new scale amount because we are not setting the scale directly
var newScale = -amount + globalScale  #  invert amount  here to change side which moves

# actually apply changes
global_scale(newScale)
``````

With this function applied to a Spatial you can set the input value `amount` to how many units you would like to scale the Spatial in global coordinates. It is not a ratio, for example if your Spatial was already 5 units long on the global X axis and you set `amount` to (2,0,0) it would scale your Spatial so it was now 7 units long on the global X axis. It should work no matter the Spatials starting rotation or scale. The camera stuff is optional depending on your use case.

Please let me know if there is a simpler way to do this, I have a feeling I have over thought it, but hey, it works!

You can just use `your_node.global_scale(scaling_vector)` on a spatial node to scale it in world coordinates. Replace yournode with the actual node and scalingvector with a vector with the scaling amount for each axis.