[Solved] Combining animation and user control

I am currently trying to have an animated object react to inverse kinematics. The inverse kinematics act properly when I have no animation running, but if there is an animation, I can’t have both working at the same time on the same bones. Either the animation is shown, (setting userControl on the bones to false), or only the IK solution is shown (setting userControl to true).



What I was going for is getting the animation to run, and then apply the IK solution after that. Since the IK solution I have right now takes the bones positions into account, I thought that I could simply take the bone positions calculated from the animation, enable userControl, set the bone positions according to the IK solution (which would have adapted to the solution closest to the animation pose) and then disable userControl, so that the next frame the animation would be able to be calculated again.



The problem I get is that when I render the frame, only the animation pose is rendered. Is there something I am not understanding here about how the final positions are calculated? It seems as though when I disable userControl, the animation pose takes over even though the animation pose was calculated before the IK solution.

So I have made some progress… The animation control actually is executed after the ik controller. So basically the ik is solving the last frame’s animation position and then the animation controller is calling skeleton.reset() which destroys all the work done by the IK.



Is there any way to set the order in which the controls are executed?

They are executed in the order they are attached.

And once again, solved just after posting the question… I had my ik control on my characterNode, and not on the model itself, so the characterNode controls were getting updated first (the ik control), then the model controls were getting updated (the anim control).



Hope this helps someone in the future. Once I am done with the IK control + constraints and my updated skeleton debugger (see my other questions) I will contribute them.