How to get the ik position of a spine constraint?

Hi there is spine.set_ik_target_position(), but is there anyway to get the ik_target position?

Maybe let’s say i want to move / translate the ik position by vmath.vector3(100, 100, 0), is it possible to do it?

Thank you

Yes, it is possible. To get the IK (Inverse Kinematics) position, you need to check the “Create Go Bones” option.


function init(self)
    self.b = false
    self.ori_pos = vmath.vector3(900, 100, 0)

    self.spine_go = "/go#spinemodel"
    self.ik_constraint_id = "target"
    spine.set_ik_target_position(self.spine_go, self.ik_constraint_id, self.ori_pos)
    self.target_go = spine.get_go(self.spine_go, "target")

    label.set_text("/go#pos_label", "IK pos : " .. tostring(self.ori_pos))
    msg.post(".", "acquire_input_focus")
end

function update(self, dt)
    print("Target world pos: ", go.get_world_position(self.target_go))
end

function on_input(self, action_id, action)
    if action_id == hash("touch") and action.pressed then
        local pos = vmath.vector3(100, 100, 0)
        self.b = not self.b
        if not self.b then
            pos = self.ori_pos
        end
        spine.set_ik_target_position(self.spine_go, self.ik_constraint_id, pos)
        label.set_text("/go#pos_label", "IK pos : " .. tostring(pos))
    end
end


画面収録 2025-11-28 23.29.46

2 Likes

Sorry, but how to get the ori_pos position? the code above hardcode the ori_pos