okay -- this does work! because add_bone uses a path so it must be doing it internally
polygon.clear_bones()
polygon.add_bone(bone.get_path(), weights)
Thank you so much!
Thanks for the reply, Twigleg!
I am indeed setting on the polygon. I tried polygon.set('bones', bones_array), but the exact same result occurs. In GDScript it's likely that polygon.bones = is just a convenience syntax for set.
This is the result of printing polygon.bones after doing polygon.set('bones', bones_array):
[[Bone2D:479641], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]
Any other suggestions? Much appreciated
Hello,
I'd like to apply twistedbone weights to polygon2d from GDscript but am having problems.
If i paint the weights in the editor, the Polygon2D's bones property will be array that looks like this: [twistedbone1,[1,1,1,1,1,1], twistedbone2,[0,0,0,0,0]] and I thought it would be trivial to set in code. But when I try to do it, weird things occur. In fact, this happens:
var bones_array = [skeleton.get_child(0), weights]
polygon.bones = bones_array
print(bones_array)
Result:
[Twisted_Bone2D:[Bone2D:24122], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]
print(polygon.bones)
Result:
[[Bone2D:24122], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]
Then when I open the weight paint screen, the right hand column that shows the bones only displays [Bone2D, instead of the usual TwistedBone_1. Weights appear set, but when i rotate the twistedbone in the editor, the polygon doesnt move with it.
So, to summarize, it seems like the TwistedBone, when set into the polygon.bones array, is being turned into [Bone2D]. Is there any way around this? I'd be fine with just a hack to get it to work.
Cheers
I'm on Godot 3.5 using the latest version of Twisted. I'm trying to set up a basic animation that moves the IK target sprite on the built in demos (e.g. 2D_Test_Scene_6.tscn) . Even though moving the target in editor mode bends the arm of the character correctly, if I move the target's position in either AnimationPlayer or a gdscript, when I run the game and it plays the animation, the target moves and so does the endpoint, but the limbs are not bending correctly.
Is there something extra I need to do to activate the entire IK chain each frame?