Home Website Youtube GitHub

Foot Roll attributes + IK/FK Matching question (SOLVED)

I’ve been modifying the EPIC mannequin rig as per the animator’s request. One of the requests was to move all the foot roll controls into attributes of the ik foot - the way I did was simply to plug these new attributes (Foot Roll, Foot Bank, etc) into their respective control’s rotation channels. Fast forward to the present, and now the IK FK matching function ikFkMatch_with_namespace(), when swapping from IK to FK, it accumulates transforms - this only happens because of the incoming connection from this foot controller’s attributes. I’ve tried looking at the code, and in this line where it resets all the foot_IK_ctls I have tried using one of your custom functions to reset all the attributes of the foot control , first using your function reset_all_keyable_attributes() and then with a simple “reset all” - neither of them worked. The first kept on giving me errors (as if it’s expecting a list and slicing whatever I give it) and the second just killed the IK FK match altogether (meaning, from IK to FK it didn’t accumulate transform, but when swapped from FK to IK it went to 0)
I don’t know if this makes any sense, the TLDR is: is there a way to make the ikfkmatch function work with a locked channel to add an attribute?
Thanks in advance.

I fixed it by adding these lines in the anim_utils.py script, under the check for FOOT cnx section, adding this:

if fk_ctrls[0].hasAttr("compRoot"):
        comp_root = fk_ctrls[0].compRoot.listConnections()[0]
        foot_IK_ctls = []
        foot_FK_matrix = []
        channel = ik_ctrl.listAttr(keyable=True) # get the keyable channel box
        foot_roll_attributes = [] # make an empty list

and then further down, after the foot IK ctls have been appended:

foot_roll_attributes = [x for x in channel if
                          str(x).endswith('Roll') or str(x).endswith('Bank') or str(x).endswith('Twist')]

Then, at the if val == 1.0 section (from IK to FK) I added this for loop under the if foot_cnx (so it only goes through it for the feet):

 if foot_cnx:
            for i, c in enumerate(foot_fk):
                c.setMatrix(foot_FK_matrix[i], worldSpace=True)
            for x in foot_roll_attributes:
                pm.setAttr(x, 0)

This has solved the problem and it no longer accumulates. Hopefully it can help someone else if they also choose to go down the foot roll attributes route over the foot roll controls!

EDIT: I don’t know how to publish code so all the indentation looks wrong… sorry about that

To make a code block, surround it with three backticks.

And if you ever need to have code with three backticks, you can surround that with four backticks.

code here