• 3D
  • Resetting to world 0,0,0

Hi, new to Godot but learning by the day. I'm rather stuck at the moment and can't go any further until this gets solved.

When I load my scene, I have my func ready() instance a few premade nodes ( meshinstane node ). I then proceed to move them around in code in this manner - translate(Vector3(x, y, z)). All is good, but what I'm trying to do is some cases I need to return these nodes(mesh) to real world 0,0,0 coordinates. I've yet to figure out how to do it in code.

Thank you for any advice.

Managed to reset to real world 0,0,0 by calling :

ent.global_transform.origin = Vector3(0,0,0)

Having no luck with the rotation side of it though.

ent.global_rotation.origin = Vector3(0,0,0)

errors out on me. I assume scale is the same way? Transform ?

global_rotation rotation is a vector:

ent.global_rotation = Vector3(0,0,0)

But it is easier to do this:

ent.translation = Vector3.ZERO
ent.rotation = Vector3.ZERO

To reset the rotation of a global transform, you can use the identity default of the Basis object, which is what stores the rotation and scale in a global transform:

ent.global_transform.basis = Basis.IDENTITY

However this will also reset the scale, as the Basis is responsible for storing the rotation and scale of a node.