I'm currently working on a 2D platformer game, in which the main character is animated using a Skeleton2D and IK. I would like to make it so that depending on which direction the mouse is pointing, the arms point up, down, left, or right. So far, I have been doing this by tweening the location of the Marker2D that is the target of each limb. While this works fine if the player faces to the right, it breaks completely once they turn around (by making the scale.x negative), and I know this is due to a bug with how Godot calculates IK. I was able to get around this for the legs by animating their rotation with an AnimationPlayer, but when I try to tween the rotation of the arms, they spasm out and do not work (see attached video). So, my question is, how would I fix my tweens to make the rotations work, and if not, is there some other way to move the arms? Any help is greatly appreciated :)
#Tweening Bone2D Rotation Not Working
1 messages · Page 1 of 1 (latest)
Also, here is the code:
func arms(mouse_angle):
move_arms = get_tree().create_tween()
move_arms.set_parallel()
if(mouse_angle<-45 && mouse_angle>-135):
#down
# move_arms.tween_property($Targets/LeftArmTarget,"position",Vector2(-32,56),0.3)
# move_arms.tween_property($Targets/RightArmTarget,"position",Vector2(36,48),0.3)
move_arms.tween_property($Skeleton2D/Torso/LeftArm,"rotation",-31.5,0.3)
move_arms.tween_property($Skeleton2D/Torso/LeftArm/LeftHand,"rotation",85,0.3)
move_arms.tween_property($Skeleton2D/Torso/RightArm,"rotation",34.1,0.3)
move_arms.tween_property($Skeleton2D/Torso/RightArm/RightHand,"rotation",-10.5,0.3)
elif(mouse_angle>45 && mouse_angle<135):
#up
# move_arms.tween_property($Targets/LeftArmTarget,"position",Vector2(28,-68),0.3)
# move_arms.tween_property($Targets/RightArmTarget,"position",Vector2(56,-56),0.3)
move_arms.tween_property($Skeleton2D/Torso/LeftArm,"rotation",-160.4,0.3)
move_arms.tween_property($Skeleton2D/Torso/LeftArm/LeftHand,"rotation",27.3,0.3)
move_arms.tween_property($Skeleton2D/Torso/RightArm,"rotation",-46.9,0.3)
move_arms.tween_property($Skeleton2D/Torso/RightArm/RightHand,"rotation",-90.4,0.3)
elif(mouse_angle<45 && mouse_angle>-45):
#left
# move_arms.tween_property($Targets/LeftArmTarget,"position",Vector2(-100,32),0.3)
# move_arms.tween_property($Targets/RightArmTarget,"position",Vector2(-44,-44),0.3)
move_arms.tween_property($Skeleton2D/Torso/LeftArm,"rotation",14.3,0.3)
move_arms.tween_property($Skeleton2D/Torso/LeftArm/LeftHand,"rotation",85,0.3)
move_arms.tween_property($Skeleton2D/Torso/RightArm,"rotation",-177.8,0.3)
move_arms.tween_property($Skeleton2D/Torso/RightArm/RightHand,"rotation",-55.6,0.3)
```