Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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. seoyeon222222

    seoyeon222222

    Joined:
    Nov 18, 2020
    Posts:
    173

    I think I found the cause
    I don't think there's a problem right now,
    but I'll try a little more and ask you again if there's a problem.


    The initialization of LookAtIK was the cause.
    It's a little messy to explain the whole accurate process in words,
    To sum it up briefly,
    I was initializing LookAtIK in this way.
    Code (CSharp):
    1. var br = new BipedReferences();
    2.         BipedReferences.AutoDetectReferences(ref br, target.transform, BipedReferences.AutoDetectParams.Default);
    3.         LookAtIK.solver.SetChain(br.spine, br.head, br.eyes, br.root);


    I switched to LookAtIK.solver.SetChain through "fbbik.references",
    It look good.


    Maybe I misunderstood something and used it.
     
  2. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    507
    I need to add some weapon place under the character's hand, but after doing this, the hand interaction targets no longer work (fingers won't match anymore) because they need to have the same hierarchy as the hand. Is there a way for this? Thanks.
     
  3. schema_unity

    schema_unity

    Joined:
    Jun 13, 2018
    Posts:
    114
    Hello Pärtel,
    I've been using FinalIK for a while now, and it really is one of the best assets for unity.

    However, I have a small problem with the behavior of weight.

    I'm using a FBBIK with targets for all limbs. In my animation system, those targets blend their transforms with transitions when needed to correct for animation jitter and surface differences. Now I would like to also blend the weight of the IK target, since in some states, not all IK targets need to be actually active, so I would like to progressively blend their weight towards 0, and then disable them during my animation transitions.

    The system I have does this already, but I noticed that there is a small "curve" the arms and legs do when the foot/hand IK target weight goes from 1 towards 0 (while animation is playing). Is there a way to blend so it looks more linear?

    Here is a video of what I mean since it's a bit hard to explain: https://imgur.com/D8d9oKz

    The goal would be that the foot goes into "locked to IK" mode without making that small curve. It's probably not trivial to do, but it would greatly enhance the fidelity of my animation transitions.

    cheers,
    - schema
     
  4. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,542
    Hey,
    Replace HandPoser component on the character's hands with GenericPoser. It is not as fast as HandPoser, but doesn't have the requirement of identical hierarchies.

    Hey and thank you!
    Could try also blending IK target position as you blend the weight to move it closer to the animated position of the bone:

    ik.solver.leftFootEffector.position = Vector3.Lerp(ik.solver.leftFootEffector.bone.position, leftFootTargetPos, ik.solver.leftFootEffector.positionWeight);

    Best,
    Pärtel
     
    schema_unity likes this.
  5. schema_unity

    schema_unity

    Joined:
    Jun 13, 2018
    Posts:
    114
    Oh thank you, that's a great idea. I'll try that.
     
  6. TommyDangerously

    TommyDangerously

    Joined:
    Oct 7, 2021
    Posts:
    1
    Hey @Partel-Lang I sent in another ticket but it looks like you're active here too! I have rearranged my Pun instantiation so that it just instantiates a prefab with vrik and vrik pun player script attached. It looks like it works but when the second player enters the room and their prefab is instantiated they freeze up and can't move. Maybe the head moves?? But the locomotion from the continuous move provider stops as well. But the animations from the xr origins hands underneath are still working. So it makes me wonder.

    EDIT: solved. Had to deactivate my XR Origins on the prefabs and let the VRIK components activate them when necessary.
     
    Last edited: Aug 28, 2023
  7. albertoforgione

    albertoforgione

    Joined:
    Jun 6, 2019
    Posts:
    14
    Hey @Partel-Lang ,

    First off, congratulations on implementing such a sophisticated plugin - absolute game changer!

    I'm currently experiencing a couple of LookAtIK related issues and I was hoping you'd be able to help out.


    1. When using LookAtIk I sometimes get the wrong look at direction on some of the characters.
    If I check in the Editor, the lines are definitely pointing to the correct target, but the body/head seems to be rotated incorrectly.

    As a temporary way round I'm now using the below the re-initiate the solver right before LookAtIK is used:

    Code (CSharp):
    1. Transform root = lookAtIK.solver.GetRoot();
    2. lookAtIK.solver.Initiate(root);
    This mostly works, however there are still a few occasions in which this doesn't do the trick.
    Please note that this doesn't happen if I replace LookAtIK with AimIK, however I need to be able to control the head/eyes weight separetely (which is not possible with AimIK), therefore I need to stick to LookAtIK for this.

    I've also tried to swap the execution order and place LookAtIK before AimIk - but to no avail.

    I'm still puzzled as to why this only happens on certain characters (they all share the same rig) - I believe it might be down to their initial animation/body orientation.
    Either way, any suggestions on a more effective way to offset and correct the initial body orientation would be appreciated.


    2. Is there any way to preserve full head movement while using LookAtIK?
    While this runs on top of the animator, if I have LookAtIK active on top of a face animation, the face movement is toned down by the look at.
    Ideally I'd like to preserve full face animation while having the character still look at the target.

    As a possible solution, I was thinking of multiplying the character's source head rotation (i.e. before LookAtIK is evaluated) with the current look at target rotation. Something like this:

    Code (CSharp):
    1. lookAtIK.solver.target.rotation *= headRotation;
    Would you think this is the right way to go about this? If that's the case, how is it possible to retrieve the source head rotation unaffected by LookAtIK calculations?
    Otherwise, please feel free to suggest a different way.

    Many thanks in advance.
     
    Last edited: Aug 29, 2023
  8. DavidM27300

    DavidM27300

    Joined:
    Sep 20, 2022
    Posts:
    6
    Hey !
    Ok I see what you mean now ! I misunderstood what you meant.
    Here is my avatar rig hierarchy :
    upload_2023-8-29_16-19-46.png

    Do you see anything that could cause that ? Because my hands are not really parented to the head, from what I understand of my rig.
     
  9. AggroG

    AggroG

    Joined:
    Jan 17, 2018
    Posts:
    1
    Hey @Partel-Lang,

    I'm having a bit of trouble with combining the Hand Effector on the FBBIK in combo with the Interaction System.

    On the interaction object, I have a position weight for the right hand which is grabbing onto a gun, I then try to go from holding it into a aim animation where I want to use the FBBIK Hand effectors to place the weapon neatly on the gun but they keep getting overriden by the interaction object setting it to 0 again, even after the interaction should have been stopped.

    The only way I've found so far was to set a quite long wait timer in a coroutine that sets the weight on the right hand effector again, but this also makes it look a bit wonky.

    Is there any good way to stop having the interact object effect the hand effector earlier or in some other way interrupt it by setting my own weight in the FBBIK (instead of it following the curve of the position weight for way longer than I feel it should)

    Thanks in advance!
     
    Last edited: Aug 31, 2023
  10. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,542
    Hey,
    Normally LookAtIK calculates the forward facing axes of the bones when it runs for the first time. So make sure the character is in the same pose when that happens (Start). Usually people have this problem when they have LookAtIK disabled by default and they enable it at a random time when they need it. So best to keep it enabled and disable it after it has initialized.
    Also, this is how you can set axes for spine, head and eyes manually:

    Code (CSharp):
    1. using UnityEngine;
    2. using RootMotion.FinalIK;
    3.  
    4. public class LookAtInit : MonoBehaviour {
    5.  
    6.     public LookAtIK ik;
    7.  
    8.     public Vector3 spineForwardAxis;
    9.     public Vector3 headForwardAxis;
    10.     public Vector3 eyeForwardAxis;
    11.  
    12.    
    13.     void Update () {
    14.         if (!ik.solver.initiated) return;
    15.  
    16.         ik.solver.head.axis = headForwardAxis;
    17.         foreach (IKSolverLookAt.LookAtBone spineBone in ik.solver.spine)
    18.         {
    19.             spineBone.axis = spineForwardAxis;
    20.         }
    21.         foreach (IKSolverLookAt.LookAtBone eyeBone in ik.solver.eyes)
    22.         {
    23.             eyeBone.axis = eyeForwardAxis;
    24.         }
    25.  
    26.         Destroy(this);
    27.     }
    28. }
    About inheriting head turning motion from animation, you'll have to update ik.solver.head.axis in every LateUpdate:

    Code (CSharp):
    1.   private void LateUpdate()
    2.     {
    3.         ik.solver.head.axis = ik.solver.head.transform.InverseTransformVector(character.forward);
    4.     }
    Hey,
    I meant the hand IK targets that you have assigned (if you have them assigned) as hand targets in VRIK arm settings, what are they parented to?
    If you don't have any hand targets, set position and rotation weight to 0 for the hands in VRIK arm settings.

    Hey,
    InteractionSystem needs to use the hand effectors so it is fighting with your script that tries to do the same thing. You can use hand effector positionOffsets to move the hands though. So instead of writing ik.solver.leftHandEffector.position = targetPos, write ik.solver.leftHandEffector.positionOffset += targetPos - ik.solver.leftHandEffector.bone.position; in LateUpdate.

    Best,
    Pärtel
     
  11. RobertOne

    RobertOne

    Joined:
    Feb 5, 2014
    Posts:
    258
    Hello everyone,

    I'm facing an issue with my character that has a scale of -1, 1, 1, meaning the X-axis is flipped. When I apply Full Body Biped IK from Final IK, the character ends up looking distorted.

    When I revert the scale back to 1, 1, 1, everything works just fine. I'm specifically interested in keeping the -1 scale on the X-axis for reasons beyond the scope of this post.

    I'm also open to using the Biped IK component. When I tried this, the arm did move, but in the opposite direction of the target. Interestingly, the character was not distorted.

    Is there any workaround to make Final IK's Full Body Biped IK compatible with a character that has a negative scale? I'm open to hacky solutions for the time being.

    Looking forward to your suggestions!

    Sovlved. just call _fullBodyBipedIK.solver.Initiate(_fullBodyBipedIK.transform); when you flip the character
     
    Last edited: Sep 8, 2023
    Partel-Lang likes this.
  12. Rawdreen

    Rawdreen

    Joined:
    Jun 9, 2020
    Posts:
    2
    Hi everyone and @Partel-Lang!

    I'm developing a game where the magician needs to arrange enchanted gems on shelves in a specific sequence (in a specific scene). I've learned how to implement the gem-picking mechanic from the Interactions demo in the FinalIK package. However, I'm struggling to find an example of how to place these gems back onto specific shelf locations. I'm currently considering using Effectors for this, but I'm not sure if it's the correct approach. How can I implement this placement mechanic?
     
    Last edited: Sep 18, 2023
  13. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,189
    I was curious whether Twist Relaxer worked on Biped IK or Full Body Biped IK? It seems I can only get this to work on a Limb IK, since the Twist Relaxer has an IK property that doesn't accept the Biped IK. Is there some trick to getting twist relaxer to work on Biped IK? Thanks.
     
  14. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,542
    Hey,
    If using interaction system, then I would create another InteractionObject, parent it to the root of the character, place it somewhere in front of him, make the position weight curve go up to 1 and back down to 0 and add an event in the middle that calls a function in your scripts to unparent the gem from the hand and add a rigidbody or something like that. Start that interaction when you need to drop the gem.

    Hey,
    Yeah, that's a bit of a problem because BipedIK is not actually an IK component, rather a collection of multiple solvers.
    Anyway, here's a more generic version of TwistRelaxer for you:

    Code (CSharp):
    1. using UnityEngine;
    2. using RootMotion.FinalIK;
    3.  
    4. public class TwistRelaxerGeneric : MonoBehaviour
    5. {
    6.     [Tooltip("If using multiple solvers, add them in inverse hierarchical order - first forearm roll bone, then forearm bone and upper arm bone.")]
    7.     public TwistSolver[] twistSolvers = new TwistSolver[0];
    8.  
    9.     public void Start()
    10.     {
    11.         foreach (TwistSolver twistSolver in twistSolvers)
    12.         {
    13.             twistSolver.Initiate();
    14.         }
    15.     }
    16.  
    17.     private void Update()
    18.     {
    19.         foreach (TwistSolver twistSolver in twistSolvers)
    20.         {
    21.             twistSolver.FixTransforms();
    22.         }
    23.     }
    24.  
    25.     void LateUpdate()
    26.     {
    27.         foreach (TwistSolver twistSolver in twistSolvers)
    28.         {
    29.             twistSolver.Relax();
    30.         }
    31.     }
    32. }
    33.  
    Just add it to the Script Execution Order to a higher value than BipedIK has so its LateUpdate would be call after BipedIK's.

    Best,
    Pärtel
     
    dgoyette likes this.
  15. Rawdreen

    Rawdreen

    Joined:
    Jun 9, 2020
    Posts:
    2

    @Partel-Lang thanks for your feedback and help !
    Just recently, I've solved my problem using your answer from this thread:
    FINAL IK - Full Body IK, Aim, Look At, FABRIK, CCD IK... [1.0 RELEASED] | Page 99 - Unity Forum
     
    Partel-Lang likes this.
  16. M-S4TO

    M-S4TO

    Joined:
    May 9, 2023
    Posts:
    2
    I am using Final IK's VRIK to control a Humanoid model.
    I want to Instantiate and display the Humanoid model at the specified head position.
    My Humanoid model is applying Animated locomotion.
    When I run the program, the Humanoid model will motion like running or vibrate for a moment right after it is displayed.
    I presume that it is an illusion that the Humanoid model has moved from the origin to the specified position at high speed.
    As a temporary workaround, I have created a script that does not render the mesh for a second or so after instantiating the Humanoid model to stabilize the display, but this is not ideal.
    Is there any solution to this problem?

    Thanks for your help!
     
  17. madcorner

    madcorner

    Joined:
    Sep 28, 2023
    Posts:
    5
    Hi, want to adjust position a bit, for example, I want to move hand a bit higher, which kind of IK that I should use?

    I've try LimbIK, I put the target transform as hand bone's child, bend target transform as fore arm bone's child, but the shoulder bone twisted and it looks not good.





    - _MainHandTarget is target transform
    - _MainHandHint is bend target transform
     
  18. madcorner

    madcorner

    Joined:
    Sep 28, 2023
    Posts:
    5
    Oh, as I try, seems like CCD IK is work as I wanted
     
  19. madcorner

    madcorner

    Joined:
    Sep 28, 2023
    Posts:
    5
  20. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,542
    Please try calling ik.solver.Reset(); after you have spawned and moved the model.

    Hey,
    Will it stop spinning if you unparent the bend target transform from the character?

    Best,
    Pärtel
     
    M-S4TO likes this.
  21. seth01plays

    seth01plays

    Joined:
    Oct 3, 2022
    Posts:
    3
    Hello Partel-Lang or to whom this may concern,
    -
    I'm attempting to achieve smooth hand transitioning between Interaction Object/ Targets, this is due to guns in my game having multiple hand positions (Charging Handle, Under barrel grips, and different sized mags). I have run into something I cant work my head around. I call some code in Image "A" to start a interaction and the hand goes to said location after snapping from the idle animation state spot. Here is a video of it happening: https://streamable.com/helk8w.
    -
    Is there a way to make it not do this? would mean so much to me if there is a cure... to this ailment.
    -
    upload_2023-10-3_20-41-45.png
    -
    -
    Image Below is of how every hand is set up.
    -
    upload_2023-10-3_20-44-54.png
    -
    -
    This is how the player body is set up with Full Body Biped IK and Interaction System.
    -
    upload_2023-10-3_20-46-48.png
    -
     
  22. hermitmode

    hermitmode

    Joined:
    Sep 15, 2020
    Posts:
    43
    Hello Partel,
    There is an issue that I have had consistently with LookAtIK, where it seems to be inverted in that if I want it to look left, the target it is looking at has to be to its right and the same with up and down. I always assumed it was something to do with rigging, that bones not properly oriented had that influence. Is this correct? Is there any other reason it would not be working? When using the AnimationRigging unity package with its native "look at" IK function it seems not to have issues. Thanks
     
  23. GoldFireStudios

    GoldFireStudios

    Joined:
    Nov 21, 2018
    Posts:
    159
    Even though I assume this is something obvious, I've run out of ideas as to what to try. I'm having an issue where pinning the hand effector to a position that is a child of the camera is not staying directly synced with the actual effector position when a walk/jog animation loop is running. This causes the hand to bob around the effector target rather than appearing fixed to it.

    In this video, the white sphere is an effector target object that is a child of the camera. The blue square is the gizmo shown by Final IK for the left hand IK position. Any ideas on what could cause these to not perfectly match?
     
  24. jjobby

    jjobby

    Joined:
    Nov 28, 2009
    Posts:
    160
    Hi Partel-Lang, do you have any tutorial about how to setup 4 legs IK for animal?
     
  25. madcorner

    madcorner

    Joined:
    Sep 28, 2023
    Posts:
    5
    No, it is spinning, is it might be because of my character model's rigging (weight painting)?
     
  26. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,542
    Hey,
    Instead of having separate interaction objects for each hand position, you should use a single one and just animate it between charging handle and other grips. If the interaction object is parented to the gun, add an Animator to it and you can create those animations pretty easily with the Animation window.

    Hey,
    LookAtIK (and other IK components) sample the pose when it first runs to find out which axes of the bones point forward etc, so even if you don't want to use LookAtIK right away, keep it enabled in Editor and disable it after it has initialized in Start. You can also overwrite LookAtIK's bone axes with a script like this.

    Hey,
    Looks like an issue with the update order of things. I think your camera updates after the IK, so even if the IK solves correctly to the position of the target that is parented to the camera, the next update of the camera before the end of the frame makes it appear wrong. You can change when you update the IK by disabling the IK component in Start and calling ik.solver.Update() whenever you need to or change the update order of your camera script in the Script Execution Order.

    Hey,
    If it's for GrounderQuadruped, it's better to use LimbIK. Go to the "Grounder" demo and copy the Grounder hierarchy from the wolf over to your own animal, then just replace all bone references in the Grounder and the LimbIK components that are parented to it. LimbIK uses 3 bones only, but even if you have more bones, you can skip some and choose the 3 bone that you want the IK to use.

    Hey,
    I don't think it's because of rigging, but I don't know what to suggest without knowing more or being able to see what your IK setup looks like. If you could package that up and send me some kind of a repro, I would take a look.

    Best,
    Pärtel
     
  27. unity_9GrkBK6e9MmiSg

    unity_9GrkBK6e9MmiSg

    Joined:
    Nov 3, 2019
    Posts:
    4
    Hello Partel-Lang!

    I have an issue with VRIK. I followed the tutorial and also read this thread.
    I managed to solve some issues with the model position and the arms by setting the model from generic to humanoid.
    But there are still some issues with the legs not bending and also when moving the head to the left and to the right the model bends from the middle. See the video below:

    I have sent an e-mail to support@root-motion.com, with more details and also a link to the model.
    Is that e-mail still valid? Because I didn't get any response.
     

    Attached Files:

  28. M-S4TO

    M-S4TO

    Joined:
    May 9, 2023
    Posts:
    2

    The method you advised worked well.
    thank you!
     
  29. madcorner

    madcorner

    Joined:
    Sep 28, 2023
    Posts:
    5
    Hello, where and how should I sent the files? should I just upload to google drive and send to your email?
     
  30. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,542
    Hey,
    That old procedural locomotion was not designed for thumbstick locomotion, it would be much better to use animated locomotion, please check out the "VRIK (Animated Locomotion)" demo about that and the Locomotion section on this page.

    Hey,
    Yes, please use support@root-motion.com.

    Best,
    Pärtel
     
  31. Namekmw

    Namekmw

    Joined:
    May 26, 2023
    Posts:
    2
    Hello Pärtel,

    I want to make a full body using 6 trackers for vrik, hands, waist, head, and feet.

    First, Change scale by calibration with T-Pose, but if you put your arm forward or up, your arm will look short or long. If I have to adjust the arm mlp by adjusting it, can you give me a hint?
     
    Last edited: Oct 19, 2023
  32. Ghosthowl

    Ghosthowl

    Joined:
    Feb 2, 2014
    Posts:
    228
    I have some logic I need to run that depends on the positioning of bones after all the Final IK code updates. For example raycasting where the origin and direction are dependent on the gun position.

    How can I call this logic where everything Final Ik needs to do has been done already? Right now I get all the pre-Ik values when using Update or LateUpdate().

    I tried
    Code (CSharp):
    1. yield return new WaitForEndOfFrame()
    and this works for most, but I am finding this does not work for particle effects that are children of the weapon.

    Is there something I have missed that can address this?
     
  33. WonkyDonky

    WonkyDonky

    Joined:
    Aug 24, 2014
    Posts:
    65
    You can subscribe to the OnPostUpdate event
    Example:
    Code (CSharp):
    1. FullBodyBipedIK yourIk;
    2. yourIk.solver.OnPostUpdate += YourFunction;
    YourFunction will get called after FullBodyBipedIK or any ik solver you use has written the solved pose
    there are others events as well (OnPostSolve, OnPostIteration etc)

    I guess one other way would be putting your script last in Unity's Project Settings > Script Execution Order
     
    Last edited: Oct 19, 2023
    Ghosthowl likes this.
  34. Ghosthowl

    Ghosthowl

    Joined:
    Feb 2, 2014
    Posts:
    228
    Thanks! I had forgot about Script Execution Order until I started testing things out. In the case of using this event though, how would I deal with all the Ik components I have? For example, my character uses Limb, Aim, Look and FBBIK - how would I go about getting the data once every component is solved? The only way I can think of is building a helper class with a frame tracker that uses these events to know when each frame has completed all Ik solves. Do-able but not as concise as I'd like.

    I guess that is what I could do. Make a helper that controls the updates manually and then have it have an event at the end of the frame that I could subscribe to. Good tip, I think that will work for me.

    Turns out my issue with ParticleSystems was solved by changing 'Simulation Space' to 'Local'. When set to 'World' nothing I did would give the final position.
     
    Last edited: Oct 20, 2023
  35. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,542
    Hey,
    If you calibrate in T-Pose, you can get the distance from left to right controller and compare it to the wing span of the model (2x arm length + (left shoulder - right shoulder).magnitude. So arm length multiplier should be ((controllerDistance - shoulderWidth) / 2f) / armLength;

    You should also try using the automated arm stretching, it just takes care of most of the arm length issues like elbow popping and too short arms. Go to the "VRIK (Basic)" demo and copy the "Stretch Curve" over from the Pilot's arm settings to your own to get a good optimal value for it.

    Hey,
    Yeah, what WonkyDonky said, but you can also just make your own IK update manager, like disable all the IK components in Start and update their solvers manually by calling ik.solver.Update() on them from LateUpdate in whichever order you need, then you can process stuff before and after every solver update. If some bones start rolling, also call ik.solver.FixTransforms() from Update on all the IK components.

    Best,
    Pärtel
     
    Namekmw and Ghosthowl like this.
  36. Namekmw

    Namekmw

    Joined:
    May 26, 2023
    Posts:
    2
    Thank you for your answer. Pärtel

    It could be a similar question
    If the arm length of the model looks longer when the arm is raised up, do I have to correct the length of the arm?
     
    Last edited: Oct 26, 2023
  37. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,542
    Probably just appears longer because the shoulder bones are rotated up when you raise your arms. Can set shoulder rotation weight to 0 if you don't like that.

    Best,
    Pärtel
     
  38. Morseliot

    Morseliot

    Joined:
    Jan 10, 2015
    Posts:
    70
    Hi Pärtel,

    What could be a reason for this kind of behaviour?

    When I try to adjust hands IK, it's bended opposite side. Wrists are twisted around itself, while the whole hand keep rotating around it's shoulder.

    Check the gif by this link
    https://cdn.discordapp.com/attachme...b09d6705227f5d3ce98eb2baa8970f48a2d4de234898&

    The IK setup configured correctly


    Some days before it was completely alright and working correctly, but then for some reason it appeared to twist like that and I can't find a reason why it happened (the rig wasn't changed).
    Can you give me a hint what could provoke it?

    Update: For some reason in the build it works as supposed, but issue exists in the editor view.
     
    Last edited: Oct 29, 2023
  39. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,542
    Hey,
    Do you have the IK component disabled when you start the scene? FBBIK samples the pose when it first runs to find out which way to bend the limbs etc, so it's best to keep it enabled by default, disable it in Start if you need to, after it has initialized. If it doesn't happen in build, it's probably a race condition of something (animation?) changing the pose before FBBIK inits.

    Best,
    Pärtel
     
  40. wechat_os_Qy030CelO4TWl89txJWTI_zE0

    wechat_os_Qy030CelO4TWl89txJWTI_zE0

    Joined:
    Oct 26, 2020
    Posts:
    2
    Hello, I want to use FullBodyBipedIk to control the hand, but the bones of the head are subdivided into multiple twist bones, which are at the same level as the hand bones. At this time, deformation occurs. Is there a solution? Thank you!
    upload_2023-10-31_9-14-24.png
     
  41. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,542
    Hey,
    This script should fix it:

    Code (CSharp):
    1. using UnityEngine;
    2. using RootMotion.FinalIK;
    3.  
    4. public class MultiParentConstraint : MonoBehaviour
    5. {
    6.     [System.Serializable]
    7.     public class Constraint
    8.     {
    9.         public Transform transform;
    10.         public Transform parent;
    11.  
    12.         private Vector3 localPos;
    13.         private Quaternion localRot;
    14.  
    15.         public void BeforeIK()
    16.         {
    17.             localPos = parent.InverseTransformPoint(transform.position);
    18.             localRot = Quaternion.Inverse(parent.rotation) * transform.rotation;
    19.         }
    20.  
    21.         public void AfterIK()
    22.         {
    23.             Vector3 pos = parent.TransformPoint(localPos);
    24.             Quaternion rot = parent.rotation * localRot;
    25.             transform.SetPositionAndRotation(pos, rot);
    26.         }
    27.     }
    28.  
    29.     public IK ik;
    30.     public Constraint[] constraints = new Constraint[0];
    31.  
    32.     private void OnEnable()
    33.     {
    34.         ik.GetIKSolver().OnPreUpdate += BeforeIK;
    35.         ik.GetIKSolver().OnPostUpdate += AfterIK;
    36.     }
    37.  
    38.     private void OnDisable()
    39.     {
    40.         ik.GetIKSolver().OnPreUpdate -= BeforeIK;
    41.         ik.GetIKSolver().OnPostUpdate -= AfterIK;
    42.     }
    43.  
    44.     private void BeforeIK()
    45.     {
    46.         foreach (Constraint c in constraints) c.BeforeIK();
    47.     }
    48.  
    49.     private void AfterIK()
    50.     {
    51.         foreach (Constraint c in constraints) c.AfterIK();
    52.     }
    53. }
    Add it to the character, assign the IK slot and make a Constraint for each twist bone:

    0:
    transform: Bip001 L ForeTwist
    parent: Bip001 L Forearm

    1:
    transform: Bip001 LUpArmTwist
    parent: Bip001 L UpperArm

    Best,
    Pärtel
     
  42. wechat_os_Qy030CelO4TWl89txJWTI_zE0

    wechat_os_Qy030CelO4TWl89txJWTI_zE0

    Joined:
    Oct 26, 2020
    Posts:
    2
    Thanks!
     
  43. Eros96

    Eros96

    Joined:
    Sep 26, 2019
    Posts:
    28
    Hi, I am playing with vrik and xr hands package to have a full body avatar with hand tracking. Right know I am trying to use the FingerRig script without success as you can see in the video. Do you have any suggestion?
    The fingerrig setup in the image below. The targets are set at runtime as the tips of the red hand.
    Thank you.

     

    Attached Files:

  44. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,279
    Heya, Pärtel.

    I'm trying to find the right magic sauce in LookAtController to avoid the neck-bending transitions that you can see here. The video clip below shows it at least 3 times.



    In this test scenario, there's a smorgasbord of potential interesting items, but only one is highlighted at a time. When the selection switches from one side of the player to the other, the internal target lerps through the head, or slerps over/under the head instead of trying to find a horizontal orbit like we would do. And it can seem neck-snapping fast even though I increase the Target Switch Smooth Time.

    Edit: Just to be clear, I am only allowing potentially interesting targets to be selected if they're forward of the character's feet. None of the neck-bending is trying to see behind the character, just switching from a left target to a right target.

    I have tried various values of Pivot Offset and speeds, but here's a sample.



    I think it's because to me it's not clear what the "pivot offset" means, or why you would not just use/specify the head bone as the pivot instead of trying to measure from the waist root.

    I'd hate to have to detect what situations are likely to snap the neck of the character, and institute a new "weight -> 0, weight -> 1" coroutine instead of your established LAC target switch behavior.
     
    Last edited: Nov 23, 2023
  45. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,542
    Hey,
    It would be much faster and easier to just rotate each avatar finger bone to match the rotation of the tracked hand.
    If the bone orientations of the model is different from hand rotation data, you can use RootMotion.QuaTools.MatchRotation() to match them.

    Hey,

    Could replace LookAtIK and LookAtController with AimIK and AimController. AimIK has another pole axis that you can use to fix a secondary axis to a secondary target. So you can add the pole target to the character, place it above the head and use head up axis as pole axis. You can also add RotationLimit components to the neck/head bones and AimIK will respect those unlike LookAtIK.

    Best,
    Pärtel
     
  46. JoeAN

    JoeAN

    Joined:
    Jun 29, 2016
    Posts:
    4
    I'm working on a project where you have pose estimation via camera body tracking that gets you the user's different body parts. I then use an avatar model and scale it to the actual user (the user stands in a T-pose and the model is calibrated such that its uniform scale is that of the x component of the user's arm span). The model has FullBodyBipedIK and its effectors' targets are set to be the transforms of the body parts that are detected by the pose estimator.

    The problem is that the models' limbs are bending more than they should (I'm using bend goals). For example, when the user is in T-pose, the model's limbs are a little bent, as if it's trying to squeeze itself to fit the user's size. Lowering the scale by some ratio after calibration improves the situation, but at the cost of visual accuracy as the model has become a little smaller than the user. Is there a way to fix this excessive bending? I've read that elbow and knee estimators are not implemented so I've tried to add them from my part. I tried expanding the effectors array to 13 elements (adding the elbows and knees) in IKSolverFullBodyBiped and adding them in the effectors enum and properties, as well as adding them in GetEffector, checking for the new length in IsValid while also adding 4 new effectors in the array initialization in SetToReferences (while also setting the respective bone references), but I'm still getting the effectors length to be 9 even when I change the length of the effectors array in IKSolverFullBody (I assume I shouldn't change it there).

    Do you think it's a good idea to add effectors? If so, how? Or is it purely a problem of scaling or bending parameters?

    Thank you.
     
  47. WonkyDonky

    WonkyDonky

    Joined:
    Aug 24, 2014
    Posts:
    65
    Is there a way to make the Finger Rig work in editor? The Editor IK script doesn't work with it.
     
  48. albertoforgione

    albertoforgione

    Joined:
    Jun 6, 2019
    Posts:
    14
    Hey Pärtel,

    I'm currently using the interaction system and facing an issue where the interaction target (right hand in my case) changes position slightly when I parent the interaction object (bottle in my case) to the character head. The bottle's position and rotation remain consistent, it's the just the hand position that changes.
    I've tried different options to tackle this, but none of them really worked out.

    1. As opposed to directly parenting the bottle to the head, I just got it to follow the head's position and rotation so that no parenting change occurs. This didn't affect the right hand position. however the rotation behaves weirdly as the beer seems to be rotating around the wrong axis.
    2. I tried to call the parenting in LateUpdate() and in the OnPostUpdate() delegate and likewise with option 1, but to no avail.
    3. As opposed to having the hand parented to the beer, as one would usually do, I tried to assign the hand to a temporary object that follows the beer's position and rotation rather than being directly parented to it, but this also didn't work.

    The even weirder thing is that I have the exact same mechanism in place somewhere else in my project, where I parent a mug to the head, but it worked straight away with the direct parenting to the head.
    I'm kinda out of options but I refuse to believe there isn't a sensible way to achieve this.

    Thanks in advance.
     
  49. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,542
    Hey,
    Definitely don't try to add effectors, it's not as simple as that I'm afraid.
    There's no perfect way to solve this as the avatar's bone structure does not match exactly to the bone structure of whoever happens to be playing the game. In my experience the best way to solve this would be to use the automatic limb stretching that VRIK has (if you can switch over to that). If you play the "VRIK (Basic)" demo and move the "TrackingSpace Pilot" gameobject up, you'll see how it works. It keeps the legs more or less unbent for a pretty large range of vertical head motion. Copy the "Stretch Curve" from the Pilot's VRIK leg settings over to your own VRIK to get the same kind of behaviour.

    Hey,
    Yeah, a bit of an oversight there, sorry... get this package please, it's called EditorFingerRig.

    Hey,
    I think it's because of the hand hierarchy changing and HandPoser doesn't like that. In the latest version I added UniversalPoser, but accidentally in broken state. Please grab this patch to fix it before I find some time to make another update. It also has the "Interaction" scene updated to use the UniversalPoser (just replaced HandPoser with UniversalPoser and clicked on Auto-Assign Bones on them and also on all the hand InteractionTargets in the scene).

    Basically it's like the HandPoser script, but doesn't require the hierarchies of the avatar's hand and the InteractionTarget to be identical. The problem with HandPoser was that once you added an item to the hand, the hierarchies would not match anymore. There's also GenericPoser that doesn't have this issue, but it requires the bone names to match and mapping is very slow because it uses those bone names. UniversalPoser uses an array of bones, so the only requirement is that the Bones added to it must match the Bones of the InteractionTarget. It also supports different bone orientations so you could use the same targets for characters that come from different sources. That's what the "Target Axis1/2" and "Axis 1/2") fields are for, you can choose 2 axes of the character's finger bones and match them to the same 2 axes of the target finger bones.

    Best,
    Pärtel
     
    JoeAN and WonkyDonky like this.
  50. albertoforgione

    albertoforgione

    Joined:
    Jun 6, 2019
    Posts:
    14
    Thanks for sending the package Pärtel, however this didn't seem to make a difference.
    As a matter of fact, I even tried to disable the UniversalPoser but the interaction target (right hand) still moved out of position.

    At this stage, this would seem related to the interaction target no longer grabbing the correct interaction object position once its parenting state change or something along those lines.

    Any more ideas?