Hello.
I am trying to convert a raycast intersected result's " position" to world space coordinates.
Though I can't seem to find a built-in function for that in Vector3 class or World3d class in docs. The result returned by raycast test is in like -2 to 2 range, which seemed to be the local space x y z between colliders.

Hence the question: so how you convert a local space result into world space coordinates?

Thanks.

  • You would use the function xform or xform_inv from the Transform class.

    I'm not sure if you can do directly from local to global space (maybe with global_transform, I haven't tried). But for going one level up you would do.

    var next_pos = your_node.transform.xform_inv(local_pos)

You would use the function xform or xform_inv from the Transform class.

I'm not sure if you can do directly from local to global space (maybe with global_transform, I haven't tried). But for going one level up you would do.

var next_pos = your_node.transform.xform_inv(local_pos)

Thanks I will see if that's what I need.

Edit: It turns out to be a bug in my position change function, sorry for the confusion.
The result.position is in 'world space' if space_state is set to world3d.direct_space_state