Set Bone2D position in script and solve IK

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Clement-O

I’m trying to create procedural animations using Bone2D nodes.
My character’s arms and legs use Inverse Kinematics and it works fine in editor.
For example : I want the hand of my character to touch a point.

For this, I wanted to simply set the hand’s position in my script

func _process(delta):
   hand.position = $"/root/Scene/Position2D".global_position

I thought it would move the hand and solve IK as it does in editor but it doesn’t, because the position property of a Bone2D isn’t modified when moving it in the editor. I’ve searched the docs to find a way to do this but I found nothing.

I thought then about writing a script to solve 2-bone IK which is not that hard. But another problem comes in : there is no way of knowing the actual position of a Bone2D in script, nor the position of the tip of the bone.

I really don’t know what to do now.