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

    amitghimire

    Joined:
    Jun 15, 2022
    Posts:
    12
    Hi I am using CCDIK to solve IK for robot arm to simulate teleoperation of a humanoid robot. Using CCDIK as I am working with rotation limits. However now I want to make the motion a bit slow(or simulate some kind of mass or inertia) so that it feels like I am not avateering the robot(like any other 3D avatar) but teleoperating it if this makes sense. Is there any way I can achieve this?
     
  2. omanuke

    omanuke

    Joined:
    May 5, 2017
    Posts:
    30
    Thanks. Is there any sample in which both system works together?
     
  3. jv_btf

    jv_btf

    Joined:
    May 14, 2021
    Posts:
    2
    Hey @Partel-Lang !
    I'm having some trouble with the Interaction System. It's really intuitive and powerful, but we want to use it in a first person perspective and it has some hiccups there.
    The full body system is great, but i really only need to use arms for this. With the fullbody setup it moves the chest and shoulders too much, which inevitably leads to clipping and "looking inside" the body and other glitches.
    I would love to stop it from doing that and instead just not fully reach the target if it would have to move the spine for it.

    I have two ideas in mind that could work here:
    1. Copy your interaction system, but limit it to LimbIKs for arms.
    2. Modify the fullbodyBiped Rig to stop the arms from moving the body.

    Do you have an idea, which of these is more sensible? Or is there another solution for it?
    Thanks!
     
  4. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,554
    Hey,

    Add this component:
    Code (CSharp):
    1. using UnityEngine;
    2. using RootMotion.FinalIK;
    3.  
    4. public class CCDSpeedLimit : MonoBehaviour
    5. {
    6.  
    7.     public float maxDegreesDelta = 10f;
    8.  
    9.     private CCDIK ik;
    10.     private Quaternion[] lastLocalRotations;
    11.  
    12.     private void OnEnable()
    13.     {
    14.         ik = GetComponent<CCDIK>();
    15.  
    16.         lastLocalRotations = new Quaternion[ik.solver.bones.Length];
    17.         for (int i = 0; i < lastLocalRotations.Length; i++)
    18.         {
    19.             lastLocalRotations[i] = ik.solver.bones[i].transform.localRotation;
    20.         }
    21.  
    22.         ik.solver.OnPostUpdate += OnPostUpdate;
    23.     }
    24.  
    25.     void OnPostUpdate()
    26.     {
    27.         for (int i = 0; i < lastLocalRotations.Length; i++)
    28.         {
    29.             lastLocalRotations[i] = Quaternion.RotateTowards(lastLocalRotations[i], ik.solver.bones[i].transform.localRotation, Time.deltaTime * maxDegreesDelta);
    30.             ik.solver.bones[i].transform.localRotation = lastLocalRotations[i];
    31.         }
    32.     }
    33.  
    34.     private void OnDisable()
    35.     {
    36.         if (ik != null) ik.solver.OnPostUpdate -= OnPostUpdate;
    37.     }
    38.  
    39. }
    Hey,
    There are some examples in the Final IK integration package in Plugins/RootMotion/PuppetMaster/_Integration/ folder. They are about stuff like aiming with an active ragdoll and applying IK before PM simulation and after PM simulation.

    Hey,
    Just set FBBIK's "Iterations" to 0, that will disable the full body solving and also give you back a some CPU budget as a bonus. :)

    Best,
    Pärtel
     
  5. amitghimire

    amitghimire

    Joined:
    Jun 15, 2022
    Posts:
    12
    Thank you!
     
  6. TakuyaBabuya

    TakuyaBabuya

    Joined:
    Dec 17, 2020
    Posts:
    9

    Hi, in the video attached, the hand target when extends beyond the body's limits does not drag the head and root of the avatar. However, if I pull the foot target lower than the body's limits, it drags everything downwards. How can I make the foot target behave like the hand target?
     
  7. jv_btf

    jv_btf

    Joined:
    May 14, 2021
    Posts:
    2
    Awesome! I knew you would have an easy fix in a robust system like this! :) Thank you !
     
  8. ml785

    ml785

    Joined:
    Dec 20, 2018
    Posts:
    119
    Hi, I am trying to get an effector to only change the calf bone's position on the Z axis, but to otherwise move the bone as it normally would on X and Y.

    I don't know how to do this in code. I tried:

    ik.solver.leftFootEffector.position = new Vector3(ik.solver.leftFootEffector.position.x, ik.solver.leftFootEffector.position.y, leftRaycastHit.point.z);

    but it's making the model move in an unexpected way.

    Edit: I think I figured out that I should use the x and y `ik.references.leftFoot.position' for what I need.

    Another questions, is there a "Left Calf" or "Left Knee" effector ?

    --

    Sorry, another question. When I set an FBBIK position through script for Left Hand Effector, it seems like the left arm's "reach" doesn't do anything, whether I set it via script or inspector.

    The only way I get 'reach' to work is if I set a Left Hand Effector "Target". Is it possible to make 'Reach' work while setting position via script?

    Edit2: All issues solved by post below, thanks so much!
     
    Last edited: Feb 23, 2023
  9. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,554
    Hey,
    If it's VRIK, disable "Plant Feet".

    Hey,
    If you want to change position only on a single axis, use LateUpdate and do this:

    Code (CSharp):
    1. Vector3 leftFootPos = ik.solver.leftFootEffector.bone.position; // the animated position of the left foot
    2. leftFootPos.z = leftRaycastHit.point.z;
    3. ik.solver.leftFootEffector.position = leftFootPos;
    I'm sorry, there's no knee effector, don't have a solution for that.

    About the Reach problem, it should absolutely work without the Target assigned. Like when I add FBBIK to the dummy, set hand position weight to 1 and move the effector in front of the dummy, adjusting Reach does have an effect. The only thing that assigning a Target actually does internally is that it simply overwrites effector.position before every update.

    Best,
    Pärtel
     
    ml785 and TakuyaBabuya like this.
  10. manutoo

    manutoo

    Joined:
    Jul 13, 2010
    Posts:
    524
    @Partel-Lang ,
    is there a full changelog (ie: Release Notes) since the version early 2020 ? (the Unity Store page shows only the last version changes)
    I'd like to review all the changes, to know if I should update or not.
     
    Last edited: Feb 24, 2023
  11. seoyeon222222

    seoyeon222222

    Joined:
    Nov 18, 2020
    Posts:
    187
    I think it was a question that many people asked,
    but I wanted to get a detailed answer after seeing your comment in the video 7 years ago.



    I have an animation requirement for two cases.
    There are 50 different humanoids.
    very big characters, very small characters, fat characters, etc. look different.

    1. All characters are
    - carry a box around
    - to mine a mineral (swing a pickax)

    2. Every character has his own weapon. (Some are shared)
    - A gladiator uses a knife.
    - The giant wields a hammer.
    - The thief throws a dagger.

    Pickaxes and knives seem similar, but they are a little different.
    Creating a unique 50 pickaxing motion for 50 different-looking characters seems too complicated.
    Should I place the item at the bottom of Hand(Child) and hard binding the animation keyframe?
    Do I have to use the Interaction Target(Final IK)? (Or another process?)
    Do I have to make 1 and 2 in a different way?

    When and what method is appropriate to use for the weapon(item) hand holding animation?
     
  12. EpicMcDude

    EpicMcDude

    Joined:
    Apr 15, 2013
    Posts:
    117
    Hi Partel,

    I'm having immense difficulty in getting my NPC to simply aim down while in a boxing stance. I have looked at your documentation, tutorial videos, demo scenes, read the scripts and nothing seems to work right for me.
    The NPC either never has the spine correctly bent towards the target, or when punching the punches do not follow the forward position of the spine.

    I know about the Aim IK script, I know about your boxing demo scenes, I have setup the NPC exactly as the Dummy was. Aim IK script on the target, Aim Pin, Aim transform on the upper arm, even tried the Aim Swinging and AimFBIK - nothing works. The NPC either bends incorrectly to the left or right or backwards or the punches go flying to left or way too down.

    I got this to work with my Player character easily because it's parented to the camera, so they just look at the target that is always forward, but with the NPC, where the target can be constantly changing and you can't control where they look with the mouse, I don't know how to set it up properly.

    Could you please just tell me, very simply, how can I make an NPC simply aim up and down and have the punches go forward?
     
  13. TheDeepVR

    TheDeepVR

    Joined:
    May 8, 2018
    Posts:
    22
    Hi, I used the old version of finalik in my project, but now when I imported the new one, I had a problem:

    The player does not cling to the floor, as it was before, now there is an indent as in the character's avatar (I have an indent from zero there of about 0.03). Is it possible to somehow fix this without resorting to changing the avatar?
     
  14. TheDeepVR

    TheDeepVR

    Joined:
    May 8, 2018
    Posts:
    22
    And I also have another question:
    I have another project on unity version 2019.3.15f1(I know that finalIK do not support this version) and before, if I changed the height of my character, then he also pressed to the floor correctly, but now the smaller the height, the more he comes off the floor
     
  15. BBZ-Game

    BBZ-Game

    Joined:
    May 19, 2021
    Posts:
    10
    Hi,Partel-Lang,
    This Demo is outdated, I have the same problem as RickyX, is there another place where I can download your Demo? I also don't quite understand the meaning of this change axis, may need your Demo to help me.
     

    Attached Files:

  16. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,554
    Hey,
    It's in the package:
    Plugins/RootMotion/FinalIK/FinalIK Change Log

    Hey,
    Depends, are your characters all custom-tailored for this game and share the same bone orientations or are they from random sources like asset packs and stuff?
    Why do you need 50 pickaxing motions, can't you use the Humanoid retargeting?

    Hey,
    Can you please share a video or something about how the NPC boxing currently looks and what is wrong about it exactly? PM if you'd prefer to not share publicly.

    Hey,
    I need more information please, like which IK components were you using?


    FIK does work with Unity 2019.3. If you're using VRIK, then one of the things that has been added to VRIK is the "Scale" parameter. That should be used when working with differently scaled avatars. So if you setup all the parameters to how you like them for a "normal" human scaled avatar, and you have another avatar that is 0.5 the size, then se Scale to 0.5 and VRIK will work exactly as it does for the other one.

    Hey,
    Sorry, I don't have a demo for Final IK. The package contains over 65 demo scenes about all the different stuff you can do with it, so I just don't know how to make a demo that shows everything. What kind of IK are you mostly interested in?

    Best,
    Pärtel
     
    EpicMcDude likes this.
  17. seoyeon222222

    seoyeon222222

    Joined:
    Nov 18, 2020
    Posts:
    187
    I'm sorry I thought something too complicated,
    it was a stupid question. You're right. If it's a humanoid, I think all 50 will work the same way.
    Can I ask you one more question?

    If the parent object needs to be changed, how should I make it?
    For example
    upload_2023-3-3_5-51-19.png
    The sword is usually bounding to the character's back.
    The sword is in the hand when attacking.

    q1) What is the recommended way to use it in this case?
    q2) Is there no problem with fat character?
    If the sword is bounding to the bone,
    In case of a fat character,
    Doesn't the sword's mesh overlap with the character's mesh?
    Should I make another child bone for bounding sword?
     
  18. BBZ-Game

    BBZ-Game

    Joined:
    May 19, 2021
    Posts:
    10
    Hello,I need the Demo explain what this line does
    "
    void LateUpdate() {
    aimIK.solver.axis = aimIK.solver.transform.InverseTransformDirection(character.forward);
    }
    "
    I want to show the correct performance in the case of
    Recoil/reload animations while aiming
    But I can't understand the parameters here, you provided a demo in the reply in 2015, which helped a developer, but this demo is on Google Drive , is no longer available for download. Is the code I mentioned used in a example included in finalik package?
     

    Attached Files:

    Last edited: Mar 3, 2023
  19. BBZ-Game

    BBZ-Game

    Joined:
    May 19, 2021
    Posts:
    10
    The best solution is whether there is a way to make a layer of animation or a single animation additive after IK. Now IK will override the shooting animation I made on the Spine. And I want to calculate IK after the other animation, and then render my additive animation on the basis of IK calculation. Is this possible in FinalIK?

    I have seen this solution in GDC sharing of DOOM‘s lookat IK, they called this behavior as preserving animation.
    "
    "
    in 13:30 - 14:12 only 42 seconds,please take a look,thank you
    upload_2023-3-3_11-14-2.png

    This is very important to me, I hope you can help me answer please.Thank you.
     
  20. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,554
    Hey,
    You don't really need any fancy IK for stuff like that. With 50 characters it is important to avoid overcomplicating things.

    You could just:
    1. Add a new gameobject to every character's hand, parent it to the hand bone, place it at the center of the grip (where the center of the sword handle would be when the hand was in gripping pose). Make sure its rotation matches with weapon rotation.
    2. Make sure every weapon has its pivot at the center of the handle
    3. Play a "grab weapon from the back" animation, add an animation event to it when the character is supposed to pick up the weapon
    4. when that event fires, parent the weapon to that new gameobject and just set its localPosition and localRotation to zero.

    That way the sword will be properly placed regardless of hand size. If hand size is still too big though and there's too much air between the hand and the sword, you can add some localRotation offset to the finger bones in LateUpdate to tighten the grip:

    Code (CSharp):
    1. Quaternion fingerRotationOffset = Quaternion.AngleAxis(angle, fingerBoneGripAxis);
    2. foreach (Transform fingerBone in fingerBones) {
    3.     fingerBone.localRotation *= fingerRotationOffset;
    4. }
    Yes, that is basically what the "Aim Swing" demo in the package does. It works the same way for recoil, reloads and equipping animations, it doesn't really matter what kind of animation plays beneath the IK. The difference between what was done in that GDC presentation and what AimIK does is that in the presentation they only rotate a single bone while AimIK can rotate an array of bones, like you can use all the spine bones (and adjust weight for each bone), not just the first. AimIK also gives you another pole target that you can use to control the up direction of the spine and also you can use rotation limit components on the bones.

    Here's a windows build for you.

    Cheers,
    Pärtel
     
    EpicMcDude likes this.
  21. seoyeon222222

    seoyeon222222

    Joined:
    Nov 18, 2020
    Posts:
    187
    Thank you for your advice.
    It was helpful!
     
  22. BBZ-Game

    BBZ-Game

    Joined:
    May 19, 2021
    Posts:
    10
    Thank you very much for your reply and example, I will study it carefully.
    And then for the content of the GDC presentation. My understanding is that since Aim IK controls a array of bones, I can't do it like in the GDC presentation with AIM IK, right? I thought all it did was render some additive animations after the IK calculation, if so, it has nothing to do with how many bones IK controls. Either I misunderstood what you meant, or I misunderstood how it was done in the GDC presentation? Could you please teach me? ThankYou.
     
  23. BBZ-Game

    BBZ-Game

    Joined:
    May 19, 2021
    Posts:
    10
    Hi,Pärtel,
    I roughly understand the meaning of modifying the parameters of the "solver.axis" line of code. I studied the demo of AimSwing, and I found that the passed parameter is a static direction, expressing the direction of swing a stick in the character space based on the neck bone(AimTransform), here is a direct edit in the scene (0, -0.3 ,1) Vector3, used to pass parameters.
    But in my current project, my character will have shooting animations in different directions and forward shooting animations to additive,For example, my character now plays a blend tree, including 10% forward shooting, 40% right shooting and 50% upward shooting. At this time, I have no way to directly define a direction to assign Yes, I may need to get the real-time direction after the animation is played to pass through the parameters.
    so the "animatedAimDirection" I need should be a dynamic direction, not just based on forward incoming from the direction. The point I'm currently stuck on is that I don't know how to get this direction value. Should I get this direction value when the animation is all completed but ik hasn't been calculated yet? Is there a time point for me to get it?
     
  24. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,554
    Hey,
    I think you can calculate animatedAimDirection from the same variables you use to drive the blend tree. Idon't know how your blend tree looks like, but I mean if your blend tree is at 40 degrees right aiming, you can set animatedAimDirection to Quaternion.Euler(0f, 40f, 0f) * Vector3.forward;

    Best,
    Pärtel
     
  25. agnoel_unity

    agnoel_unity

    Joined:
    Nov 8, 2022
    Posts:
    1
    Hello, Partel! We're using your Aim IK for our third-person gun aiming but continue to have problems with overlaying animations with the aim. Our set-up is:
    • Aim IK affecting only a lower spine that has no animation data
    • The Aim IK target is a game object at the tip of gun muzzle
    • The lower spine has a Hinge Limit to only allow rotating left/right. This also allows the upper spines to do recoil and reload animations independently
    • The upper body is an override layer and the base layer controls a strafing blendtree
    Specifically, we're having problems with any animations that make the gun point fully up or down. You can see it here when the gun is being flipped in the air:


    I have tested using the IK "additive" mode that is used in the Aim Swing and Aim Controller scripts which fixes the flipping but introduces a new problem. Now when changing between strafe directions the gun aim becomes offset from the target (it is aligned correctly for strafing left, but angles away from the target when strafing right), as seen in this video:


    Appreciate any insights into what is going wrong here and/or what some better practices we could implement are.
     
  26. BBZ-Game

    BBZ-Game

    Joined:
    May 19, 2021
    Posts:
    10
    Hi,Pärtel
    My blending tree is like this.
    upload_2023-3-10_16-38-20.png
    I will use the direction formed by the passed x, y as the parameter of the blending tree to select the animation playback ratio, but the animation mixed in this direction is not very strictly pointing to the direction I passed in This direction, because we do not have strict requirements on how many degrees must be upward and how many degrees to the left in animation production, and according to my own experiments, even if the animation is strictly 90 degrees upward and 90 degrees left 50 It seems that the final result does not necessarily point to the upper left 45 degrees, so I mean that if you want to get the direction that the final blend tree animation points to, you may only get it from the time point after the animation is played, and only know the blend parameters There seems to be no way to know the exact direction the animation was actually pointing in the end.
     
  27. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,554
    Hey,
    I see, the problem comes from Animator blending locomotion animation with upper body animation with an upper body mask. It doesn't work quite well for aiming because hip rotation comes from locomotion and the upper body aiming animation doesn't have curves for the rest of the spine bones to compensate for that and keep the aiming steady.

    I have a solution for that, but it's quite messy as it requires having a second character rig and another animator to play the upper body animations (instead of a layered animation setup), then blend the 2 together via script and apply AimIK on it for steady aiming. Here's the package with a demo scene.
    As I said, it's a bit of a hack, which is why I haven't added it to Final IK.

    You can see that the dummy has an Animation Mixer gameobject parented to it and that has another instance of the dummy and the AnimationMixer component. That is what does all the locomotion-aiming blending. You can set "Aim Weight" on it to 0 to see how it would look without the AimIK fix.

    Hey,
    In that case I'm out of ideas. But why do you need all those aiming animations there anyway, AimIK can pretty nicely give you at least 90 degrees of aiming freedom in any direction.

    Best,
    Pärtel
     
  28. BBZ-Game

    BBZ-Game

    Joined:
    May 19, 2021
    Posts:
    10
    Well, in fact, because Aim IK only supports controlling a single bone chain, we chose to use BlendTree and AimIK at the same time. The animation in our BlendTree will rotate many bones that are not on the same chain for different aiming directions, so as to show a more natural effect. If there is no way to additive the additive animation of the recoil after AimIK takes effect, then I can only consider trying to remove BlendTree and only use AimIK. Thank you for your answer
     
  29. BBZ-Game

    BBZ-Game

    Joined:
    May 19, 2021
    Posts:
    10
    To put it succinctly, I want animation and AimIK to follow this order of effectiveness.

    Aimed Idle Animation -> AimIK -> Recoil Animation.

    If it is not possible to separate the calculation order in this way, I may need to be able to calculate the direction at this time in real time at the time point at the first arrow.
     
  30. Daniel_mab

    Daniel_mab

    Joined:
    Mar 2, 2020
    Posts:
    5
    Hi! I wanted to ask you if it's possible to limit the procedural steps of "VRIK" within the perimeter of a collider like at minute 0:58 of this video:

    Thanks!
     
  31. Dainofel

    Dainofel

    Joined:
    Oct 12, 2019
    Posts:
    35
    Hello,

    I have bought and currently implementing this asset. I have a question - is there a way to obtain the final hand positions, after IK has modified the animation, before LastUpdate ends?

    I am working with ECS. I need to send a raycast from the weapon to a point, and I need the updated hand positions after IK (at the moment, the ray is being casted from the hand positions before IK corrects it)

    Being able to get the updated hand and weapon positions after IK has ran would allow me to do the raycast with the updated positions and solve the delay that is currently happening.

    Thanks for your help
     
  32. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,554
    That's not possible, sorry.

    Hey,
    I don't have a solution for that. There is a hidden feature in VRIK that can make procedural locomotion stop at obstacles like tables and fences, allowing you to bend over them without stepping into them (in IKSolverVRLocomotion_Procedural.cs, remove [HideInInspector] from lines 124 to 127), but I don't have anything similar to what you showed in the video. The easiest to make something like that would be to go to that same .cs file where on line 424 you have private bool StepBlocked(Vector3 fromPosition, Vector3 toPosition, Vector3 rootPosition).
    Make a raycast down from above "toPosition" and make the function return true if it doesn't hit anything.

    Hey,
    All ik components have the OnPostUpdate delegate that will be fired every time when the solver finishes solving

    Code (CSharp):
    1. public IK ik;
    2.  
    3. void Start {
    4.     ik.GetIKSolver().OnPostUpdate += AfterIK;
    5. }
    6.  
    7. void AfterIK() {
    8.     // read hand positions from here
    9. }
    Best,
    Pärtel
     
    Daniel_mab likes this.
  33. TheDeepVR

    TheDeepVR

    Joined:
    May 8, 2018
    Posts:
    22
    Hi, I want to turn off hand animation, but when I turn it off in animation mask - nothing changes.
    I want the hand to be straight, i.e. the fingers should not be bent(like on first screenshot) upload_2023-3-17_19-50-46.png
    upload_2023-3-17_19-49-8.png upload_2023-3-17_19-49-32.png
     

    Attached Files:

  34. NewMagic-Studio

    NewMagic-Studio

    Joined:
    Feb 25, 2015
    Posts:
    454
    Partel, i sent you emails about VRIK but you don't reply them. I have two problems, the upper part of the body moves right often, don't know why, how can i make it stay still? head and upper part of body moves right and then feet moves too when there is enough distance but i don't want upper part of body moves in first place
    Also another problem is that sometimes the body goes on tiptoes and other times knees are bent, should be always the same is like character looks as if had shorter legs sometimes and other times legs look longer
     
  35. AxelGogoris

    AxelGogoris

    Joined:
    Jan 8, 2020
    Posts:
    5
    Hey :)
    Hope you're doing well and thanks for your hard work!
    I'm using VRIK and I have a question with hands target. Sometimes, I want the hand to follow a target and sometimes I don't. But when I decide to stop following the target, the arm should try to keep its place while still following the general body movement (like the head). I don't want it to go back to its default position but I don't want it to stay "locked" in a position either. Like, how could I deal with this: "Note that if you have nulled the target, the hand will still be pulled to the last position of the target until you set this value to 0" (VRIK - Position weight for the arm class) without setting the value to 0 and thus completely resetting the position. Is it possible?

    Have a great day :)
    Axel
     
  36. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,554
    Hey,
    Unity doesn't like AvatarMasks on the base layer. If a body part is masked, it will pose it in this weird default pose, which has all the muscles at 0 angles (half way from negative to positive limit) and that's why your fingers are bent. You could play another animation that has the fingers straight on top of base layer with just the fingers enabled in the mask.
    Or store all finger bone localRotations in Awake and enforce them to default in LateUpdate.

    Hey,
    Can't think of anything that would make the head move right, is the head IK target moving right too or is the head separating from its IK target?
    About tiptoeing, reduce Body Rot Stiffness and Neck Stiffness, move the camera closer to the head bone if possible.
    Also, enable foot stretching. To do that, go to the "VRIK (Basic)" demo and copy the Stretch Curve from the Pilot over to your own character.

    Hey,
    Something like this>

    Code (CSharp):
    1. using UnityEngine;
    2. using RootMotion.FinalIK;
    3.  
    4. public class VRIK_ToggleHandTargetFollowing : MonoBehaviour
    5. {
    6.     public class Hand
    7.     {
    8.         private IKSolverVR.Arm arm;
    9.         private Transform target;
    10.         private Vector3 relPos;
    11.         private Quaternion relRot = Quaternion.identity;
    12.         private Transform root;
    13.         private bool isFollowing;
    14.        
    15.         public Hand(IKSolverVR.Arm arm, Transform root)
    16.         {
    17.             this.arm = arm;
    18.             this.root = root;
    19.             target = arm.target;
    20.             isFollowing = true;
    21.         }
    22.  
    23.         public void SetTargetFollowingEnabled(bool value)
    24.         {
    25.             if (value)
    26.             {
    27.                 arm.target = target;
    28.                 target.position = arm.IKPosition;
    29.                 target.rotation = arm.IKRotation;
    30.             }
    31.             else
    32.             {
    33.                 arm.target = null;
    34.                 relPos = root.InverseTransformPoint(arm.IKPosition);
    35.                 relRot = Quaternion.Inverse(root.rotation) * arm.IKRotation;
    36.             }
    37.  
    38.             isFollowing = value;
    39.         }
    40.  
    41.         public void LateUpdate()
    42.         {
    43.             if (!isFollowing)
    44.             {
    45.                 arm.IKPosition = root.TransformPoint(relPos);
    46.                 arm.IKRotation = root.rotation * relRot;
    47.             }
    48.         }
    49.     }
    50.  
    51.     public enum Handedness
    52.     {
    53.         Left = 0,
    54.         Right = 1,
    55.         Both = 2,
    56.     }
    57.  
    58.     public VRIK ik;
    59.     private Hand leftHand, rightHand;
    60.  
    61.     private void Start()
    62.     {
    63.         leftHand = new Hand(ik.solver.leftArm, ik.references.root);
    64.         rightHand = new Hand(ik.solver.rightArm, ik.references.root);
    65.     }
    66.  
    67.     private void LateUpdate()
    68.     {
    69.         leftHand.LateUpdate();
    70.         rightHand.LateUpdate();
    71.     }
    72.  
    73.     public void SetTargetFollowingEnabled(Handedness handedness, bool value)
    74.     {
    75.         if (handedness == Handedness.Left || handedness == Handedness.Both) leftHand.SetTargetFollowingEnabled(value);
    76.         if (handedness == Handedness.Right || handedness == Handedness.Both) rightHand.SetTargetFollowingEnabled(value);
    77.     }
    78.  
    79. }
     
    AxelGogoris likes this.
  37. AxelGogoris

    AxelGogoris

    Joined:
    Jan 8, 2020
    Posts:
    5
    Wow, thank you so much for your time and for this precise answer! Thanks a lot :)
     
    Partel-Lang likes this.
  38. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,561
    UPDATE: I changed the Velocity Prediction to 0 and everything seems too work.

    Screen Shot 2023-03-30 at 4.04.16 PM.png

    Im using the scripts and setup from the CCD IK spider example. After a while walking(or sometimes on start) my spider legs just stopped walking. It looks like the final node on the CCD IK chain (the foot) gets "stuck" in a world space position. Here you can see the first 4 blue dots line up with the leg, but the last dot is way off in the distance which is where the spider was originally placed. This also happens when walking where a working leg will eventually see its last blue dot get stuck where it steps. Then the leg just tries to reach out to it, resulting in spider legs reaching and no longer walking.


    Screen Shot 2023-03-30 at 3.26.55 PM.png

    I also notice in the initial object there's only 4 blue dots. Is this extra one generated at runtime only, and that's what the leg is trying to reach?

    Screen Shot 2023-03-30 at 3.30.51 PM.png
     
    Last edited: Mar 30, 2023
    Partel-Lang likes this.
  39. mrphilipjoel

    mrphilipjoel

    Joined:
    Jul 6, 2019
    Posts:
    61
    Greetings. I'm using VRIK.
    Is there a way to disable VRIK's control of the legs?
    I'm doing a superhero game, and I have a 'hover' animation that positions the legs into a super floaty pose.

    I have tried putting a mask on the VRIK Animator layer, to mask out the legs, but VRIK still seems to control the legs a bit (and make my animation look really funky).

    If I completely disable VRIK component, my hover animation looks great, but I can no longer control the hands or head of avatar with my XR controllers.
     
  40. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,554
    Hey,
    Just remove all leg bones from VRIK's "References".

    Best,
    Pärtel
     
  41. amitghimire

    amitghimire

    Joined:
    Jun 15, 2022
    Posts:
    12
    Hi, This might not be the place to ask this question but just trying out my luck if someone using this tool might have done something similar already . I am simulating teleoperating a humanoid robot(arm) movement with CCDIK and Kinect. To make it realistic, I am planning to play some motor sound effects when the arm moves. If it was animated I am guessing I could have coupled animation with audio playback. But since I am using tracking my hand and translating that to the robot motion using IK, not sure how to play audio effects when the arm moves without triggering the audio playback all the time. Any guide or ideas ?
     
  42. mrphilipjoel

    mrphilipjoel

    Joined:
    Jul 6, 2019
    Posts:
    61
    I am not sure I fully understand what you're doing, but could you get the position of the 'hand' of the robot arm, and play the audio effect if the change in position (delta) is over a certain amount?
     
  43. mrphilipjoel

    mrphilipjoel

    Joined:
    Jul 6, 2019
    Posts:
    61
    I am having issues with VRIKCalibrationBasic

    It scales my avatar just fine for taller users (I am 6ft, and if I stand on tip-toes, and recalibrate it does great, if a squat just a little bit, it does fine too).

    But, if I get on my knees, to where I'm around 4ft tall, it doesn't scale less than .99 on my avatar.

    Docmentation says, I could just do some math and scale the avatar myself:

    If you only need to calibrate the size of the avatar, it is easiest to do so by having the player stand up straight, then comparing the height of the head target to the height of the avatar's head bone:

    float sizeF = (ik.solver.spine.headTarget.position.y - ik.references.root.position.y) / (ik.references.head.position.y - ik.references.root.position.y);
    ik.references.root.localScale *= sizeF;
    I may resort to that, but I like the VRIKCalibrationBasic because I can set the headAnchorPositionOffset and my camera and headtarget will move with the scale, so it stays in front of the eyes, instead of getting "absorbed" into the head of the avatar.

    Edit: It's also worth noting, that if I calibrate, and scale goes above 1, let's say to 1.2, if I squat in real life, and try recalibrating again, scale will stay the same. It won't go lower than its current value.
     
  44. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,554
    Hey,
    Use a looping sound and just control the volume of it (and maybe pitch if you like) based on the angular velocity magnitude of the joints. You can use this function to calculate angular velocity:

    Code (CSharp):
    1. /// <summary>
    2.         /// Returns angular velocity from lastRotation to rotation
    3.         /// </summary>
    4.         public static Vector3 GetAngularVelocity(Quaternion lastRotation, Quaternion rotation, float deltaTime)
    5.         {
    6.             Quaternion rotationDelta = rotation * Quaternion.Inverse(lastRotation);
    7.             float angle = 0f;
    8.             Vector3 aV = Vector3.zero;
    9.             rotationDelta.ToAngleAxis(out angle, out aV);
    10.             if (float.IsNaN(aV.x)) return Vector3.zero;
    11.             if (float.IsInfinity(aV.x)) return Vector3.zero;
    12.             angle *= Mathf.Deg2Rad;
    13.             angle /= deltaTime;
    14.             angle = QuaTools.ToBiPolar(angle);
    15.             aV *= angle;
    16.             return aV;
    17.         }
    Make sure to run this code after the IK has updated, using ik.solver.OnPostUpdate delegate or LateUpdate of a script that has a higher value in the Script Execution Order than FIK components have.

    Hey,
    That "float sizeF = (ik.solv..." math is exactly what the calibrator does under the hood. But you can always rescale the avatar after the calibration to whatever you need, or clamp it like> ik.references.root.localScale = Mathf.Clamp(ik.references.root.localScale.y, 0.7f, 1.3f) * Vector3.one;

    Also, it might be worth considering to just keep all the avatars scaled at (1, 1, 1). Shorter people probably prefer to not appear shorter in VR. They will not be able to reach the ground, but everybody is way too lazy to crouch down anyway. A good force grab mechanics takes care of that problem and gives you one less problem to worry about.

    Best,
    Pärtel
     
  45. sarahrothberg

    sarahrothberg

    Joined:
    Aug 7, 2017
    Posts:
    2
    hellllo! this is my favorite plugin ever and i'm so appreciative of its existence!

    I am trying to use VRIK + Humanoid Baker to be able to capture animations I do with a headset + controllers in real time as humanoid animations so I can play them back later. I felt so sure I have everything set up correctly! But I get this error when I hit record:

    NullReferenceException: Object reference not set to an instance of an object
    RootMotion.HumanoidBaker.UpdateHumanPose () (at Assets/Plugins/RootMotion/Baker/Scripts/HumanoidBaker.cs:170)
    RootMotion.HumanoidBaker.OnSetKeyframes (System.Single time, System.Boolean lastFrame) (at Assets/Plugins/RootMotion/Baker/Scripts/HumanoidBaker.cs:151)
    RootMotion.Baker.LateUpdate () (at Assets/Plugins/RootMotion/Baker/Scripts/Baker.cs:422)

    I'm on 2021.3.1 !

    THANKS!! <3
     
  46. chilton

    chilton

    Joined:
    May 6, 2008
    Posts:
    564
    Is there something like legLengthMlp but for the spine?

    I want to let the user specify their height, leg, and arm length, but there's no obvious way I can find for setting how far their head is from their pelvis.

    Obviously for some people it's super close :D

    Thank you,
    -Chilton
     
  47. ok8596

    ok8596

    Joined:
    Feb 21, 2014
    Posts:
    40
    Hi, is there anything like Reset() for LookAtIK?
    If I attach to a character that is bending its neck at the first frame, the IK will look in the wrong direction.
     
  48. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,554
    Hey,
    Only thing I can think of, maybe your Animator component is missing an Avatar? If not, can you send me a repro package or something please?

    Hey,
    No, but you could just multiply the localPositions of all spine bones in LateUpdate by a scaling factor.

    Hey,
    LookAtIK samples the pose at start to find out the forward facing axes of the bones. So it is usually best ot start the character with LookAtIK enabled, then disable it in Start if you don't need it right away. If it still doesn't work right, you can override those axes with a script like this:

    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. }
    Best,
    Pärtel
     
    ok8596 likes this.
  49. chilton

    chilton

    Joined:
    May 6, 2008
    Posts:
    564
    That gives me an idea, is there a way for me to tell VRIK to 'restart' after I change offsets of body parts?

    If so... I noticed it gets things right if I manually move the local positions of various bones of feet, arms, spine, and neck before I hit play. I could put a component on the VRIK object that would push the offsets to where they need to be, then call VRIK to restart.

    Is that possible?

    -Chilton
     
  50. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    281
    Hello, before buying I would like to know if this solution is able to rig all kind of creatures? like spider, centipede, scorpion, other monsters...
    Gotta ask because I go through your video tutorial playlist and only see videos about biped character.