Is there a way to move from Animation to Animator without lost of scripting freedom?

The problem is: I use legacy Animation. I need to play animations randomly and load them from resources. I need to have access to the event that current animation finished. All this works fine in legacy.
But now I need to add the IK in my program which is not present there (Am I wrong?). So I have to move to Animator I suppose. Is there a way to built such a random state machine by script and on runtime?
Thanks for any help in advance.

You should look into the Playables API. The Animator component itself is indeed more restricted than the legacy Animation system, however, it’s also more powerful for specific tasks. The Playables API works with the Animator, but allows runtime generation, custom nodes, mixing, I assume basically everything the legacy system allowed you to do from code, but internally it also uses the modern Animator features, so it should work for your use-case. But, I don’t know about IK within Playables specifically, I just assume you can configure it as part of the regular Animator at least.