Search Unity

FINAL IK - Full Body IK, Aim, Look At, FABRIK, CCD IK... [1.0 RELEASED]

Discussion in 'Assets and Asset Store' started by Partel-Lang, Jan 15, 2014.

  1. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hey, why not, although someone already used that demo in a recent game jam :).

    Could you explain, I didn't understand, what did you mean by " the "pelvis" needs to be the shoulders(?) or the spine where they attach". FABRIKRoot is not good for animated characters, I would not recommend it. If you explain me the problem, I can probably suggest another solution.

    Best Regards,
    Pärtel
     
  2. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hey,
    I updated the Playmaker bridge to Unity 5.2 and the latest Playmaker and added a very basic demo scene.
    Please reimport the package.

    Cheers,
    Pärtel
     
  3. carlosrovira

    carlosrovira

    Joined:
    Dec 23, 2014
    Posts:
    58
    Thanks Partel!
    just imported it :)

    Some question after checking it a bit:

    a) What is the "interrupt" control?
    b) In some combos there's "None" but there's no more options, what's the purpose? I think you only can switch to "variable mode" and make an assignement...

    Thanks!
     
  4. carlosrovira

    carlosrovira

    Joined:
    Dec 23, 2014
    Posts:
    58
    One more thing...
    In the "Start Interaction" Action, There's an "Effector Types" and shows a text input with a "0".
    This should not be a combo with the possible effectors?
     
  5. carlosrovira

    carlosrovira

    Joined:
    Dec 23, 2014
    Posts:
    58
    forgot it, I saw this is an array and as you put a number it populates the combos. Sorry for the noise :)
     
  6. wetcircuit

    wetcircuit

    Joined:
    Jul 17, 2012
    Posts:
    1,409
    I apologize if I do not use correct terms.

    My figure hangs from the wrists. I am using FBB-IK effectors to pin the wrists, and to animate the ankles and spine. (left hand, right hand, body, left foot, right foot)

    I've uploaded a 1min video (probably not safe for work) http://www.3d.wetcircuit.com/xtra/FBBIK/hanging-IK-web.mov

    my issues are:
    1) the wrists aren't staying in one place (hands slide up and down)
    2) the "center of gravity" or the "base of the rig" is still the hip joint. I am thinking it should be between the shoulder blades because the figure is hanging...?

    My newbie idea of how to "fix" what I am seeing:
    a) try a different IK solution
    b) edit FBBIK's Reference joints so the IK treats the upper spine joint as the "pelvis"
    c) re-bone the figure so it's base "hip" is the upper spine
    d) admit this is too advanced for me and not worry about it (although I would like to get the wrists to pin better)

    Thank you for taking the time. Your suggestions are appreciated.
     
  7. carlosrovira

    carlosrovira

    Joined:
    Dec 23, 2014
    Posts:
    58
    Hi Partel,

    I want to request a Interaction Trigger Video Tutorial. I think you already have it mind. I'm trying to use it, but still is like a black box for me :)

    It's possible?

    Thanks!
     
  8. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hi! if "interrupt" is true, the interaction will be (re)started even if the effector is already in interaction. If not, it will ignore the call until the effector has finished any ongoing interactions.

    Hi, thanks for the clarifications (and the video :)).

    First, you can make the wrists pin better if you set both arm "Pull" values to 1 and both leg "Pull" values to 0.

    If you need to control the chest better you can do so by using the shoulder effectors. Make a duplicate of the chest bone, unparent it from the character, delete all except the chest and upper arm bones. Assign the upper arm bones as the shoulder effector targets and weigh in shoulder effector weights. You can then move and rotate the chest by the duplicate chest bone.

    You should not edit your character hierarchy the way you described, it would not work like that.

    Have you seen the "Mapping to Ragdoll" demo scene? It might be possible to set up the rig like that, it would be more physically accurate.

    Yes, I was planning to do that, probably tomorrow or Friday, hold on :)

    Best Regards,
    Pärtel
     
    wetcircuit likes this.
  9. ataraxia

    ataraxia

    Joined:
    Mar 25, 2015
    Posts:
    4
    Hello Partel,

    Thank you so much for your amazing asset! This opened up so much more possibilities for my project. I have a newbie question, though. I emailed to support@root-motion.com but I figured this forum thread would be more proper place.

    I need to get the final transform of a game object which is parented to another game object with FK+Final IK animation. I couldn't really find where to get the final FK+IK transform used for rendering the scene.

    Below is what a simple pseudo code for what I’m trying to do

    //---------------------------------------------------------------------------------------
    public GameObject attachedObj;
    public GameObject boneObj;

    void Start()
    {
    // boneObj is a bone object in a game object with Animator & LookAtIK component.
    // attachedObj is voxel mesh object which doesn't have animation of its own but parented to the boneObj above.
    attachedObj.transform.parent = boneObj.transform;

    // initial transform setting is same to the bone.
    attachedObj.transform.position = boneObj.transform.position;
    attachedObj.transform.rotation = boneObj.transform.rotation;
    }

    void Update()
    {
    // I'm trying to get player's position in a voxel coordinate space of this attachedObj
    Vector3 playerPosLocalToVoxel = new Vector3();

    // Here, world-space playerPosition is converted to attachedObject's local space coordinate(which is parented to an actual FK+IK animating bone).
    // I was assuming attachedObj.transform is FK+IK at this point but this only gave me FK result.
    playerPosLocalToVoxel = attachedObj.transform.localToWorldMatrix.inverse.MultiplyPoint3x4(GetPlayerWorldPos());

    // use this to get voxel space grid coord snapped to integer coordinate.
    Vector3 playerVoxPos = GetVoxelCoord(playerPosLocalToVoxel);
    }
    //---------------------------------------------------------------------------------------​

    Q: what callback function should I use to get the final FK+IK result of an object?
    Q: should I use ik.Solver to access each bone's IK applied transform instead of trying to get it from gameObject.transform itself?
     
  10. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hi, Ataraxia, and thanks!

    All IK components update in LateUpdate, they read the animated pose, solve and write the results back on the character. If you take a look at the Script Execution Order, you'll see that Final IK components have assigned them to very high values so they run after your own LateUpdate code (so you can make adjustments after animation and before IK). You can either disable the IK components and update them manually in LateUpdate by
    Code (CSharp):
    1. ik.solver.Update();
    after which you'll have the final solved transforms and a chance to read them. OR you could just use the OnPostUpdate delegate as such:

    Code (CSharp):
    1. public FullBodyBipedIK ik;
    2.  
    3.     void Start() {
    4.         ik.solver.OnPostUpdate += AfterIK;
    5.     }
    6.  
    7.     void AfterIK() {
    8.         if (!enabled) return;
    9.  
    10.         // IK has solved by now
    11.     }
    12.  
    13.     void OnDestroy() {
    14.         if (ik != null) ik.solver.OnPostUpdate -= AfterIK;
    15.     }
    Cheers,
    Pärtel
     
    ataraxia likes this.
  11. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    montyfi likes this.
  12. carlosrovira

    carlosrovira

    Joined:
    Dec 23, 2014
    Posts:
    58
    Thanks Partel! Great tutorial as always.

    Now at last...I can see the light hehe :)
     
    Partel-Lang likes this.
  13. thorgaming_42

    thorgaming_42

    Joined:
    Sep 25, 2015
    Posts:
    13
    Hey Partel, I have been loving your script, the interaction system alone has given me so many ideas for game play and also helped me to build more realistic ai bots.

    I am using FullBodyBipedIK AimIK LookatIK GrounderFBBIK and the RagdollUtility, the problem occurs when the bot dies and switches to a ragdoll it will basically go crazy as though something exploded inside the ragdoll!

    I have tested different orders of initiating the components or doing a manual update similar to your lookat+aimik tutorial but nothing is working 100%. I just wondered before i get too specific if there is anything I should be doing when combining so many features and switching to ragdoll. I see the ragdollutility disables the ik components but i still see to get varying results disabling things myself.

    Many Thanks in advance great product.
     
  14. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hi, just a quick counterquestion, have you updated to the latest Final IK (1.1)? Because there was a problem with 1.0 RagdollUtility not working with Unity 5.2, but it has been fixed.
     
  15. thorgaming_42

    thorgaming_42

    Joined:
    Sep 25, 2015
    Posts:
    13
    My Final IK is up-to-date, I think i may have isolated the problem, its where I was using one of your locomotion animator setups but i had added the aiming layer from a different demo, I think the ragdoll was failing when this layer was active, I did notice some import warnings on the animation but i'm more code based, the animation side is new to me :)
     
  16. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Does the problem still remain when you disable all IK before going to ragdoll?
     
  17. ataraxia

    ataraxia

    Joined:
    Mar 25, 2015
    Posts:
    4
    Aha! Thank you so much for the quick response! This perfectly solved my problem. Now my voxels are happy with new IK friends. :)
     
    Partel-Lang likes this.
  18. Slowbud

    Slowbud

    Joined:
    Jul 19, 2015
    Posts:
    81
    Hi Partel, i'm running in a problem when animating some parts with FinalIK.
    I've set up a muscle bulging and flexing system which is driven by the angles of the body part joints.

    E.g. when I need to know how much the left biceps should flex, I read the left elbow joint with:

    lLowerArm = animator.GetBoneTransform (HumanBodyBones.LeftLowerArm);
    lAngleLowerArmY = lLowerArm.transform.localEulerAngles.y;


    Now FinalIK overrides these angles in LateUpdate and FinaIK and Unity transform have different values. Or better, transform didn't change the angle value.

    Is there an easy way to get the resulting angle from FinalIK like the in the above mentioned code? Maybe my question is similar to the one from "ataraxia", but to be honest, I didn't understand the answer, due to I'm not too expierenced. Just need a code line which works for FinalIK ;-)
     
  19. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hey,
    So the problem is that you are reading the transform's euler angles before Final IK does it's changes to the pose?

    In that case just use the same code as I pasted to Ataraxia:

    Code (CSharp):
    1. public FullBodyBipedIK ik;
    2.     void Start() {
    3.         ik.solver.OnPostUpdate += AfterIK;
    4.     }
    5.     void AfterIK() {
    6.         if (!enabled) return;
    7.         // IK has solved by now
    8.     }
    9.     void OnDestroy() {
    10.         if (ik != null) ik.solver.OnPostUpdate -= AfterIK;
    11.     }
    Just put your angle reading code below "IK has solved by now" in the AfterIK callback.

    Pärtel
     
  20. Slowbud

    Slowbud

    Joined:
    Jul 19, 2015
    Posts:
    81
    Thanks Pärtel for the fast response, now I understood, works great now.
    It seems FinalIK has a solution for everything. ;-)

    Bernhard
     
    Partel-Lang likes this.
  21. SunnySunshine

    SunnySunshine

    Joined:
    May 18, 2009
    Posts:
    977
    Pärtel,

    Can you explain why/how these three are different?

    1. FBIK iteration = 4.
    2. FBIK iteration = 1, but doing solver.Update() 4 times (in a loop).
    3. FBIK iteration = 4, but doing solver.Update() 4 times (in a loop).

    Is there a way to make the second or third option behave more like the first one?

    I need to update several skeletons that are dependent on each other, so I need to do something like option 2 or 3 above (like your kissing rig example). However, I have noticed that even when I only have 1 character in the scene using this technique, the result is vastly different from having a single solve with iteration 4. If you have a hand target that's causing the character to stretch, the character will stretch far more in option 2 and 3 than in option 1 - even when setting pull and stretch to 0.

    EDIT:
    Nm, obviously I should fix transforms each time.
     
    Last edited: Sep 29, 2015
  22. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
  23. immeasurability

    immeasurability

    Joined:
    Apr 22, 2014
    Posts:
    125
    hi!, in version 1.0 when use 2d coordinate for 2d game this work good, but when scale player for flip direction (1,1,1) -> (-1,1,1) get epic treble. did you have solution, or this complete in 1.1?
     
  24. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hi! which IK component are you using?
     
  25. immeasurability

    immeasurability

    Joined:
    Apr 22, 2014
    Posts:
    125
    this was problem on CCDIK and on FABRIK too
    on CCDIK epic bad
    on FABRIK bad
     
  26. immeasurability

    immeasurability

    Joined:
    Apr 22, 2014
    Posts:
    125
    and if real use custom anatomy for Full Body Biped IK? or or there is an alternative?
     
  27. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Currently non-uniform scaling is not supported. It is generally very bad to use (-1, 1, 1) scale on a hierarchy of gameobjects, it messes up a lot of stuff like colliders (3D colliders at least), making trouble when rotating the objects, its bad for the performance and so forth. Would it be possible to rotate the character around Y 180 degrees instead and just flip the sorting? If you write to me to support@root-motion.com with some pictures or a package or something, I could probably me more helpful.

    FBBIK doesn't work with 2D at all, what do you mean by custom anatomy?

    Cheers,
    Pärtel
     
  28. immeasurability

    immeasurability

    Joined:
    Apr 22, 2014
    Posts:
    125
    yes this work Y 180 degrees, but leave for later

    Full Body Biped IK work on two hand and and legs, how about 4 legs?
    or tail of the snake without legs naga?
    or 4 hand like shiva?
    or centaur 4 legs?

    how use Full Body Biped IK for this? can have an alternative way to control your character?

    I very very very very very very much like your product!!!!
    I want to manually create the skeleton for Full Body Biped IK!!!
     
  29. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    You can combine FBBIK with other IK components to achieve this effect. Take a look at this video (from 01:00).
    So for example if you had a 4-armed creature, you could choose one pair of arms to be dominant and assign them to FBBIK and then solve the remaining arms with LimbIK on top of that. You'll have to make sure the IK components update in the right order (FBBIK first, other after that), you can attach the IKExecutionOrder.cs component for that.
     
  30. Nadan

    Nadan

    Joined:
    Jan 20, 2013
    Posts:
    341
    Hi!

    I have a very I quess basic question. In my game the character gives items to the player and I try ty animate it with FinalIK. So I have assigned FullBodyBibedIK and behind the camere there is a cube that represent the player. I have put the cube in the Left Hand Effector Target, and when I move the Position Weight value the character smoothy gives the item to the player while maintaining Idle (or whatever is going on) animation. This looks great.

    Position Weight 0



    Position Weight 1



    Now my problem is how do I animate this? I tried to animate the Position Weight value with the Unity Animation system, but coudn't get it to work (or did something wrong). I quess this could be done by scripting also? What I try to do is animate the value Position Weight from 0 to 1 and back to 0. This looks like the character is giving an item to the player.
     
  31. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    Hi there Partel,

    Im testing the very new "Third Person Controller Template" on asset store but is not working well with Final Ik. Using Final IK the animations become jaggy as hell, its like every plugin is trying to force the bone position.

    Any idea what could be causing this? I think its something related with the "Update" method, but you said that all IK components work with "LateUpdate".
     
  32. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hi!

    Have you tried the InteractionSystem?

    Hi, a few questions:
    does the character's animator run in "Animate Phsyics" update mode?
    Which IK components are you using and how, are the components updating their solvers or have you disabled them and updating manually?

    Cheers,
    Pärtel
     
  33. Nadan

    Nadan

    Joined:
    Jan 20, 2013
    Posts:
    341
    This is perfect. Thanks!
     
  34. ggrin

    ggrin

    Joined:
    May 20, 2013
    Posts:
    6
    Hello Again Partel,

    Found out new problem recently while being swithcing to Unity 5.2:

    LimbIK jitters with animator with Physics Update mode in the next pipeline:

    1. Instantiate GO with animator and some base bones, then I add the hand bones with LimbIK to it
    2. Also tried fixed LateUpdate
    3. It starts to jitter changing hand bones' positions between animation and positions calcualted by IK.

    was fine in 5.1 =(
     
  35. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Congrats, you have found another Animator bug introduced with 5.2. I have already reported 4, beat that! :)

    Did some tests. When you instantiate an Animator and change it's update mode to Animate Physics via code, it will not update in fixed timestep, but keep updating each frame as it was on Normal (set your time scale to 0.1, you'll see it is still smooth). IK thinks it's on Animate Physics and updates in fixed timestep so there's your jitter.
    A quick workaround was to change the Animator to AnimatePhysics already in the prefab.

    I don't know what happened to the Animator in 5.2, it has become extremely delicate and I am afraid to touch it. :)
     
    hopeful likes this.
  36. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    ... I made a quick repro and bug report to Unity (734432).
     
    Last edited: Oct 8, 2015
  37. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    Hi there Partel,

    The plugin its using a Coroutine to project raycasts and detect if the character should be crouching etc...
    Also the plugin is using FixedUpdate to update animations at the animator controller (Mecanim) and LateUpdate to Handle Input.

    Tested on Full Body Biped IK and Biped IK.

    On Biped Ik the bug is only noticiable when using Grounderer.

    And Yes, the bug its related to Animate Physics (plugin is changing it on runtime).
     
    Last edited: Oct 8, 2015
  38. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Thanks for the additional info.

    Basically the idea is that IK must be solved when and only when Animator has updated, it is like a layer applied on top of the animation. Unfortunately the Animator updates secretly and tells no-one about it so we have to guess. When the update mode is on Normal, it will update each frame between Update and LateUpdate, if it's on AnimatePhysics, it will update only on fixed frames after FixedUpdate. But maybe the Animator is disabled and updated manually or maybe the bug we just found 2 posts ago is messing everything up. The sole purpose of SolverManager.cs in FinalIK is to guess when the Animator has updated, that is 150 lines of code. :)

    Anyway, you have to disable the IK components and then you have to know when the Animator is updated by the plugin in fixed time step and when it is updated each frame, then update IK accordingly using ik.solver.Update();

    Pärtel
     
  39. montyfi

    montyfi

    Joined:
    Aug 3, 2012
    Posts:
    548
    I always thought that OnAnimatorMove and OnAnimatorIK was intended to use especially for that same reason. Maybe I'm wrong.
     
  40. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    OnAnimatorIK I can't use, the Animator has not applied it's transformations yet, so it will overwrite whatever changes you make. The same problem with OnAnimatorMove.
    I could use OnAnimatorMove to know which frame the Animator updates in and use LateUpdate to apply the IK later, but you would not be able to toggle "Apply Root Motion" anymore, it would become "Handled by Script".
    Also, it doesn't obviously work with Legacy and it would not work at all in the case of Animator being disabled and updated manually in FixedUpdate before PhysX solves.

    We would need something as simple as MonoBehaviour.OnAnimated that is called right after animation is applied on the hierarchy by both the Animation and Animator components. I made a hopeless feature request almost 2 years ago, I should probably try some other channels.
     
    hopeful likes this.
  41. montyfi

    montyfi

    Joined:
    Aug 3, 2012
    Posts:
    548
    Gave you all my votes :)
     
    Partel-Lang likes this.
  42. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,686
    If you haven't yet, try mentioning it directly to @Mecanim.Dev.
     
    WendelinReich likes this.
  43. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Hello Partel,

    I just got your asset today, what a wonderful asset it is!! I am very impressed that it work out of the box. I used the asset to ground my character (foot ik) and I couldn't believe that I just applied a couple of your script and it worked like a charm! thank you so much...

    Regards,
    Carlos
     
    Partel-Lang likes this.
  44. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Already did that last week, waiting for reply ;)

    Hey, thanks for stopping by to say that, it means a lot :)

    Cheers,
    Pärtel
     
  45. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hi! That bug is fixed in Unity 5.2.1p3 patch release.

    Good day,
    Pärtel
     
  46. montyfi

    montyfi

    Joined:
    Aug 3, 2012
    Posts:
    548
    Hi Partel,
    I need advice, how my setup should look like if I want functionality of interaction system, but instead of touching object by hand I want it to be touched by sword in hand?
    Another case, I want to touch shoulder by sword of the same character.
     
    Last edited: Oct 14, 2015
  47. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hi,
    Basically you can use the sword exactly the same way as the hand. Just pose the hand with the sword as you want it to be touching the object and use it as the InteractionTarget. You can then assign a Pivot so the target can rotate around it towards the character so the object could be approached from different angles.

    Touching a shoulder can be done the same way, but as long as the interaction doesn't pull the shoulder away, because once FBBIK reads in the IK targets, it can't update them during the solving process, that would require mapping to be done in each solver iteration step.

    Pärtel
     
    montyfi likes this.
  48. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Partel, I have FinalIK and have used the Grounder component a few times in my project, but the results have been not quite as good as I would have expected. I was looking for a grounding solution ever since the old Locomotion system became obsolete since it didn't support mecanim. I finally found this, but I am wondering it FinalIK Grounder can perform with the same level of precision and realism as the old locomotion. With the demo of the pilot, he moves around so fast that he virtually glides over terrain and I can't really tell anything unless you stop and look at the foot placement. In that sense it's great, but what I'm looking at is the step up/down look that was achieved with locomotion. Watch this video to see what I mean.



    When the character comes to a big step up, it literally knows it needs to step up/down and takes a very precise step up/down and places a foot. It's so very nice. Is this achievable with FinalIK Grounder? If so, what kind of settings are needed? An example of a slow moving character in the old locomotion demo scene would be a great comparison if anyone has it.
     
  49. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hi!

    About the old Locomotion system, the Grounder is completely another thing, it is not a procedural locomotion, but a foot placement correction system. I agree the Locomotion was good for stepping up/down stairs, but it came at a cost of responsiveness and required much more effort setting up and motion analysis which is probably why it was not possible/reasonable to make it work with Mecanim. It also tends to produce awkward results from time to time as you can see also from the video you shared.

    You can make the pilot go slower by holding shift, that will make him walk. Hold ctrl for slow motion.

    Cheers,
    Pärtel
     
  50. Hedonsoft

    Hedonsoft

    Joined:
    Jul 11, 2012
    Posts:
    168
    Hi Partel.

    When my character picks up a weapon I want to have several HandPoser targets on d9ifferent parts and lerp between them to position the hands depending on which action is being performed.

    What I'm thinking is when the pickup interaction is triggered an array of handposer transforms on the weapon or item are stored, and then when different actions are performed (reloading, cocking, etc) the character hands lerp to the appropriate handposer transform.

    Is this possible? and if so can you give me an example or point me toward one that shows something similar?
     
    Last edited: Oct 16, 2015