Search Unity

Can the IK constraint be only applied after the animation transforms?

Discussion in 'Animation Rigging' started by wafflesGama, Feb 5, 2020.

  1. wafflesGama

    wafflesGama

    Joined:
    Mar 29, 2019
    Posts:
    15
    I've been trying to make a Feet Placement Ik system with Two Bone IK constraints following a target that follows the feet's position after each animation pass. But I can't seem to figure out how disable the constrains weight before and enabling after each animation pass.
    I've tried changing the weight values on the FixedUpdate to zero and OnAnimatorMove following the target and changed the weight to 1 but this appends:
    ezgif.com-video-to-gif (2).gif
    Code (CSharp):
    1.  private void OnAnimatorMove()
    2.     {
    3.         rFootConst.weight = 1;
    4.         lFootConst.weight = 1;
    5.        
    6.        (...changin target position to foot location)
    7.     }
    8.  
    9. private void FixedUpdate()
    10.     {
    11.         rFootConst.weight = 0;
    12.         lFootConst.weight = 0;
    13.     }
    The green rectangles are the IK targets and I presume the weight becomes zero before the constraint tries to blend the feet position with the IK target, any sugestions?

    (Also I would like to suggest an option for the Two Bone IK Constraint to only follow certain axes, in this case i have would needed to follow the Y axis of the target)
     
  2. simonbz

    simonbz

    Unity Technologies

    Joined:
    Sep 28, 2015
    Posts:
    295
    Hi wafflesGama,

    Animation Rigging is executed during the ProcessAnimation phase alongside FK animation. Therefore, you cannot use a callback to change constraint values in between FK animation and Animation Rigging (Refer to https://docs.unity3d.com/Manual/ExecutionOrder.html for a detailed look at Unity's evaluation order).

    In order to control the weight value of your constraint, you should implement a custom contraint that will evaluate before your IK and write the weight value you intend the IK to have in the animation stream.

    If you need help implementing constraints, have a look at the SIGGRAPH 2019 workshop we did last summer that covers the implementation of several custom constraints:

    https://github.com/Unity-Technologies/animation-rigging-workshop-siggraph2019
     
    Last edited: Feb 6, 2020
    wafflesGama likes this.
  3. wafflesGama

    wafflesGama

    Joined:
    Mar 29, 2019
    Posts:
    15