Hi,
I am trying to programmatically pin my character's arm to a point (ledge grabbing). I have a SkeletonUtilityBone set to Override, and when I want to pin the arm, I enable it and continuously set the world position to the desired point during Update().
This works, but I have an issue where the arm stutters while a parent bone is rotated. The parent bone is rotated to follow the mouse cursor for aiming a gun. The arm IK is a child of this rotated bone so that the arms will rotate with the gun. In my ledge grab scenario though, I want the child arm to stick to a specific point. So Spine is fighting to rotate the arm with the parent, then I pull it back into my desired place, and the result is a stuttering while aiming.
Is there a better approach I can take? Any suggestions?
One thought I am trying out, is to turn off IK (set the Mix to 0) for the arm to be pinned, and then just use the IkConstraint to calculate the bone SRTs and update them myself, like
Vector2 ledgePoint = ... // the world point to pin to
SkeletonUtilityBone armIK = ... // the arm IK bone
IkConstraint c = ... // the arm ik constraint
armIK.bone.x = ledgePoint.x;
armIK.bone.y = ledgePoint.y;
armIK.bone.UpdateWorldTransform();
IkConstraint.Apply(c.Bones.Items[0], c.Bones.Items[1], armIK.bone.WorldX, armIK.bone.WorldY, c.BendDirection, 1f);
but still trying to get that to work
Thanks for the help
16 Mar 2016 10:14 am
I just read about Transform Constraints, Use case for transform constraint
Is that something I could use to solve my issue?