Search Unity

Playables and Foot IK

Discussion in 'Animation' started by SOICGeek, Aug 25, 2020.

  1. SOICGeek

    SOICGeek

    Joined:
    Jun 25, 2019
    Posts:
    78
    I'm trying to learn how to use Playables. Following the code here, I can get an animation to play just fine, except it doesn't apply foot IK properly. If I put the same animation clip into an AnimatorController, I can go to the state and check "Foot IK" and it plays correctly. Back to the Playable code. There are two function calls that I could find that had anything to do with IK: AnimationClipPlayable.SetApplyPlayableIK() and AnimationClipPlayable.SetApplyFootIK(). Neither one has any effect. I have tried both together, each one separately, and placing it before my call to Play() and after. I also tried calling it every frame. Using the PlayableGraph Visualizer, it shows that the values ApplyFootIK and ApplyPlayableIK are indeed being set, but the feet are still sliding around all over the place. As stated above, placing the exact same animation clip in an AnimatorController, and then marking the animation state's "Foot IK" checkbox works, but I don't think encapsulating every single animation clip in an AnimatorController is intended behavior. I want to use the Playable API, because I like the flexible nature, but not being able to use foot IK is something of a deal breaker.

    Here's my code:
    Code (CSharp):
    1. private void Start() {
    2.  
    3.         // creating the PlayableGraph - 'graph' is declared as a field
    4.         // in the class declaration
    5.         graph = PlayableGraph.Create();
    6.  
    7.         // creating an output
    8.         AnimationPlayableOutput output = AnimationPlayableOutput.Create(graph, "Idle", anim);
    9.  
    10.         // setting the update mode to automatically update
    11.         graph.SetTimeUpdateMode(DirectorUpdateMode.GameTime);
    12.  
    13.         // 'acp' is declared as an AnimationClipPlayable field in the class
    14.         // idleClipGraphs is a list, and chooseRandom() is an extension method
    15.         // from my own library
    16.         acp = idleClipGraphs.chooseRandom();
    17.  
    18.         // neither one of these work, either together or separately.
    19.         acp.SetApplyFootIK(true);
    20.         acp.SetApplyPlayableIK(true);
    21.        
    22.         // adding the clip to the graph
    23.         output.SetSourcePlayable(acp);
    24.  
    25.         // playing it
    26.         graph.Play();
    27.  
    28. }
    The animation plays just fine, but the feet slide around, rather than being planted like if I use an AnimatorController. Anyone that can tell me what I'm doing wrong? The API documentation is a little skimpy on a lot of these function calls.
     
  2. YONCE1999

    YONCE1999

    Joined:
    Apr 6, 2021
    Posts:
    1
    Same questions i met, Did you sloved it?@SOICGeek