Why is global_transform returning an error for a node under a BoneAttachment3D?

Godot Version

4.7

Question

I’m trying to create a script that attaches a picked up object to the hand of a 3D player. It does this by running an animation that lerps between the object’s starting global transform and a target transform I specify. When that target is a Marker3D that is a child of my player object, this the animation runs smoothly. However, when I target a second marker attached to the hand of my animated skeleton, it causes this error:

E 0:00:19:238   item_carrier.gd:105 @ _physics_process(): Condition "!is_inside_tree()" is true. Returning: Transform3D()
  <C++ Source>  scene/3d/node_3d.cpp:649 @ get_global_transform()
  <Stack Trace> item_carrier.gd:105 @ _physics_process()

My second target node is the grip_left node that is a child of an imported skeleton rig:


This line causing the error is:

		var target_xform:Transform3D = target_node.global_transform * offset

Is there a way to set things up so that my script can get the global_position of grip_left?

The error means that target_node isn’t in the scene tree.

But it is. It’s the grip_left node which is a child of the skeleton, which is a child of my player character.

Looks like I had to move my grip_left node to be outside of the skeleton and a child of my player character. And then I added a RemoteTransform3D as a child of the BoneAttachment3D and set it to copy its transform to grip_left. After that, I was able to get the global_transform of the grip_left node.