I want to make a human portrait which's angle of arms can change by the environment,
to make the arm looks correctly, I add the constraint on it
there is a IK chain with 3 bones and 1 helper, and the middle bone has a constrain.
So it would look like this, looks fine in editor
I use this code to change the helper's position
man.SetBonePosition("hand position", target.position, Space.World);
However, It would only return a folding hand in the game
If the IK has no constraint, it could work normally
How do I use the IK constrain when the help's position is changed by code?
Hi, HongEn Tsai!
Thank you for writing the post.
Most of the IK operations in the editor and in the game are almost identical.
So if it works the way we intended, IK should give the same result in both the editor and the game.
Looking at the screenshots you have attached, it seems that the result is incorrect by IK Constraint, and we ask you to check two points.
1. Adjust the IK Constraint angle of the character's shoulder.
The screenshot above shows the IK Constraint of the elbow (or lower arm), but not the shoulder IK angle.
However, in our opinion, it is the IK angle of the shoulder (or Upper Arm) that affects the "wrong result".
Please, try adjusting the IK Constraint of the character's shoulder and elbow.
Our recommendation is to set the shoulder's IK Constraint to a fairly wide range, and conversely, limit the elbow's IK range to less than 180 degrees.
Currently, the range of the IK Constraint for the elbow looks rather large. Try reducing the angle so that the lower arm does not overlap the upper arm.
In particular, in this case, further reducing the range of the IK angle of the lower bone seems to produce good results.
(This isn't always the perfect answer, so try varying your IK settings!)
2. Did the helper's position as the effector bone teleport?
AnyPortrait's IK is calculated based on the result of the previous frame, so if the "Helper" bone moves continuously, it will show more natural results.
It doesn't seem like this will make the result completely wrong, but we'd like you to check this point as well.
Reading your post, it seems that there are no major problems with your workflow.
In our opinion, if you try to adjust the IK settings, it will probably solve this problem easily.
If that doesn't fix the problem, please let us know further detailed settings.
We will continue to help.
Thank you!