How to place bones in Skeleton3D at given positions

Godot Version

4.3

Question

I have a skeleton whose bones I want to place along a path. I have a path follow node for each bone so each bone can sample a position from the path and move to that position.

However, I’m getting lost in the world space / local space stuff and not quite getting the results I want. This is my code:

for i in float(bone_count):
    var percent: float = i / bone_count
    path_follow_nodes[i].progress_ratio = percent
        
    var rest = snake_skeleton.get_bone_global_rest(i)
    var new_pose = rest.translated(path_follow_nodes[i].global_position)
        
    snake_skeleton.set_bone_global_pose(i, new_pose)

Here’s a video of it in action, where the green line shows the path and the balls are examples of path_follow_node.global_positions to showcase that those positions are legitimate positions on the path.

This code is the closest I’ve gotten it to work, but it’s not quite there. I’m trying to get those bones to match that path, but as you can see there’s an offset that gets bigger the more I move away from the center of the world, and it follows the rotation of the model instead of being stuck to the actual position of the path.

Does anyone know where I’m going wrong and how I can fix it?