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

    jcbhmmn

    Joined:
    Oct 4, 2014
    Posts:
    16
    Hi Partel,

    I am running into a problem using VRIK with Steam VR where the avatar hand drifts/floats from the true position of the controller. When using Oculus, there is no problem, the avatar hand is tight to the controller position. To recreate: I am using Unity 2018.2.20f1 with the latest version of Final IK (from this October), and latest version of SteamVR and Oculus Integration. Do you know of any way to correct this drift? See video for clarification:

     
  2. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,053
    Damn! But I think Pärtels pretty close
     
  3. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Hey,
    Not sure if I understood, but you could add 2 AimIK components - one for the spine and the other for the neck and head. Also add the IKExecutionOrder component to make the head one update after the spine one. Then you can set individual values for those solvers, add RotationLimits to the bones if necessary to define the axes of rotation. You'll also get 2 targets, so you can make the chest look at one position and the head another.

    Hey,
    Nothing to rewrite really, just add in the steam camera prefab parent the head and hand IK targets to the steam head and hand controllers, then remove the oculus prefab. Here's a tutorial for steam setup.

    Hey, happy birthday!

    Did you mean the tracking latency of HTC Vive? Don't know the milliseconds exactly, but should be unnoticable. About VRIK, it moves the body to the tracked positions immediately, so no additional latency from that.

    Hey, thanks for the inspiration :).
    Their arm model seems pretty good, doesnt seem to have shoulder bones though. And adding bendable spine and lower body will make everything much more complicated. Anyway, I'm about to rewrite VRIK arm solver, because I'm tired of it twisting up the wrists and stuff, hopefully will be done early next year.

    Hey,
    Only reason I can think of why this could happen is that VRIK is updated before SteamVR updates the hand positions for the frame. Do you have VRIK component enabled or are you updating it manually some other time by calling ik.solver.Update()? Normally VRIK updates in LateUpdate and it has a very high value in the Script Execution Order, to make sure it updates after everything else and it can get the hands to the targets without any delay.

    Best,
    Pärtel
     
  4. Chobacka

    Chobacka

    Joined:
    Apr 4, 2018
    Posts:
    1
    Hello,
    I'm using the calibrator to set a vrik player and I can't figure out how to make the feet stay above the ground when bending down. It finds all the target positions fine and the model looks good, but even with grounders and what not the feet keep going through the ground. If I just set the character to the camera without calibration everything works fine, but that's not what I'm after. I'm using the the standard oculus camera. Is there something I am missing when setting up the model with the calibrator? Is there a simple solution for keeping the ground level on a calibrated player?
     
  5. jcbhmmn

    jcbhmmn

    Joined:
    Oct 4, 2014
    Posts:
    16
    Hi Partel,
    I am not doing anything special to VRIK component, simply using the VRIK (Steam VR) Demo Scene. I am using the latest SteamVR Unity Asset (Version 2.0.1). I have also tried with earlier versions of the Steam VR Unity Asset and get the same drift. I have asked a friend to test using the same conditions (Latest Unity, Latest Final IK, and Latest Steam VR) and has confirmed the same drift issue. It is causing me problems as I am attaching a game object to the avatar hand for gameplay, but the drift is making precise interactions difficult. Let me know if there is anything I can try to correct this.
    Thanks!
    Jacob
     
  6. a-t-hellboy

    a-t-hellboy

    Joined:
    Dec 6, 2013
    Posts:
    148
    Thanks for replying.

    I want something like Fortnite which is in idle state.
    BTW how can I set my target to camera look rotation ?

    Edit: I put a gameObject in the scene and its position is updated according to camera. Is it OK ?
     
    Last edited: Dec 24, 2018
  7. blacksun

    blacksun

    Joined:
    Aug 29, 2010
    Posts:
    22
    Hi,

    I'm just getting started here with Final IK and VRIK integration using Oculus Utilities.

    First off, please forgive my ignorance, I'm quite a beginner.

    I followed your VRIK steam integration video, but using Oculus, and got that setup. I then wanted to add the calibration script to be able to set the correct character height.

    It seems that each time the default re-calibration key is pressed, (C), the height is set correctly, but the character rotates -90 degrees.

    I'm wondering what I've done wrong.

    I made a video to illustrate the issue.



    Thanks-
    -Tobias
     
  8. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    366
    I really love what you did in "Interaction Walls" scene! I mean touching walls is something I can't ignore but there is a big issue :( If you just move a bit far from origin/pivot point (2000 or even less) it doesn't work correctly anymore!!! Can you please check to see if there is a way to solve this?

    Move everything on that scene just 2000 away from origin point and then see what will happen :eek:
     
  9. ProtoPottyGames

    ProtoPottyGames

    Joined:
    Dec 18, 2015
    Posts:
    43
    Just have a quick question about the most recent update (1.8).
    I was wondering about the legless character support bit. Is there something in particular I need to do for this? Or does it just work regardless of whatever ik setup im using? Maybe I missed something in the docs? Just want to make sure I don't shoot myself in the foot for what I've got planned for the rest of my rig. Thanks! :D
     
  10. a-t-hellboy

    a-t-hellboy

    Joined:
    Dec 6, 2013
    Posts:
    148
  11. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Hey,
    Usually, when feet go below the ground, it happens when people try to use Generic animation on a Humanoid or vice versa so the character goes into this default sunken pose that Mecanim for that scenario. Please disable IK and see if the character looks normal in the animation.

    Hey,
    OK, looks like my integration package is out of date and the prefab connections broken, just updated it. But that was not the problem with the lag. Find the "SteamVR_Settings" file in the Project Window and change "Pose Update Mode" to "OnLateUpdate". Its defaulted on OnPreCull which happens after VRIK update so VRIK will lag a frame behind.

    Hey,
    Yeah, that is fine.

    Hey,
    There have been a couple of bugs with VRIK root rotation fixed since the last version. Please try if this patch takes care of the problem first.

    Hey,
    Parented that entire scene contents to a new gameobject at (0,0,0), then moved that object to (2000, 0, 0). The animation and IK seemed all the same to me. Only saw some pretty significant shadow flickering problems that are to be expected at that range due to floating point precision issues. What exactly did you see?

    Hey,
    Yeah, so just don't assign any leg bones in the References, that should be all. You'll need to make the root of the character catch up with the HMD when you move though. Just smoothdamping towards the horizontal position of the HMD should be fine:

    Code (CSharp):
    1. float rootV;
    2.  
    3. void LateUpdate() {
    4. Vector3 dir = ik.solver.spine.headTarget.position - ik.references.root.position;
    5. dir.y = 0f;
    6. ik.references.root.position = Vector3.SmoothDamp(ik.references.root.position, ik.references.root.position + dor, ref rootV, smoothTime);
    7. }
    Hey,
    I have seen some weird leg bending, but never seen any weird hip action like that. Could you send me that character fbx and the walking or running animation to support@root-motion.com so I could take a closer look?

    Best,
    Pärtel
     
    ProtoPottyGames and a-t-hellboy like this.
  12. a-t-hellboy

    a-t-hellboy

    Joined:
    Dec 6, 2013
    Posts:
    148
    Sent
     
    Partel-Lang likes this.
  13. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    366
    But what if I need to just move character 2000 away not the whole scene? :)
     
  14. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Should be the same, I mean, I just moved the scene too so the character would not be alone in space.
     
  15. kblood

    kblood

    Joined:
    Jun 20, 2012
    Posts:
    76
    I have been trying to get VRIK to work with Puppet Master, to make a VRIK active ragdoll... mainly to ensure that you cannot push your hands through walls and such. But I have run into a few problems. One is that I cannot get the body to follow me when I climb, and another is it affects my movement when I walk.

    I made a short video about it:


    Got any tips?
     
  16. blacksun

    blacksun

    Joined:
    Aug 29, 2010
    Posts:
    22
    Hi, I applied the patch but the issue remains.
     
  17. chainsawpenguin

    chainsawpenguin

    Joined:
    Sep 28, 2014
    Posts:
    98
    Good evening, team!

    I can't find an answer to this, but I'm sure someone else has experienced it. Basically, my knees are backwards.

    Steps:
    1 - I added a FBBIK script to my player, and verified that all of the mecanim bones were mapped correctly.
    2 - I a GrounderFBBIK script to the same GameObject, and made sure that the Layers was set to "Ground" and "IK" was set to the FBBIK above.

    I did not change any other settings.

    My character now runs as if he has goat legs, with knees that bend backwards.

    Any ideas?
     
  18. ProtoPottyGames

    ProtoPottyGames

    Joined:
    Dec 18, 2015
    Posts:
    43
    Do your character's bones by chance come from the Mixamo (Adobe) auto-rigger? If so, you need to put some bend in them prior to hooking them up to Final IK so the solver doesn't get confused. (Actually I don't think this is necessarily exclusive to the Auto-Rigger, just common to it.)
     
    chainsawpenguin likes this.
  19. chainsawpenguin

    chainsawpenguin

    Joined:
    Sep 28, 2014
    Posts:
    98
    It's actually a rig I built in blender. Hmm.. Okay, I'll see if I can dope out what it needs. Thanks.
     
  20. VrTechEx

    VrTechEx

    Joined:
    Aug 4, 2013
    Posts:
    30
    Hi Partel,

    I have an issue with Interaction Trigger. Can I use physics.spherecast instead of the sphere collider?
    I work on the Multiplayer networking and I found that Collider acts weirdly even though isTrigger is checked.

    Any solutions? Thank you.
     
  21. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Hey,

    Looks like the character is just left behind when you climb up as the built in locomotion only works horizontally. When using PuppetMaster with VRIK, you should have the character parented to the gameobject that you move when you locomote or climb. Also set the Animator to AnimatePhysics, ragdoll rigidbodies to interpolate and also the rigidbody that you use to move around. That should take care of the jitter you are seeing when you move. It would be also better to set locomotion weight to 0 and use an animator controller with a strafing locomotion blend tree to make it follow the direction of your movement and input. Here's a few examples for you, import to a new project with just PM and FIK inside.

    Hey,
    Could you please send me that scene as a unitypackage, I haven't managed to reproduce this problem here.

    Hey,
    Please check out this tutorial, basically just need to rotate the knee bones in the editor a little bit so FBBIK could calculate the leg bending direction.

    Hey,

    Yes, but you'd have to change InteractionSystem.cs a bit. Comment out OnTriggerEnter and OnTriggerExit starting from line 642. Then add void FixedUpdate and put your spherecasting code in that. If the spherecast finds an object with the InteractionTrigger component, do inContact.Add(trigger): If not, inContact.Remove(trigger).

    It would be slower than the normal trigger collider solution though, so it might be a good idea to try to figure out why the collider "acts weirdly" instead.

    Best,
    Pärtel
     
  22. valentin_bourdon

    valentin_bourdon

    Joined:
    Sep 17, 2015
    Posts:
    9
    Hi Partel !

    Thanks a lot for your asset, it's really impressive !
    I have a question about CDD classe, for the moment you can only follow the target position. But, I would like also follow the target rotation. Have you got an idea to implemented this ?

    Best,
    Valentin
     
  23. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Hey,
    Not possible with CCD nor FABRIK, sorry, it's just the nature of those algorithms.
    I've found that you can actually solve most industrial rigs with PhysX though. Please import this example package.
    It shows you how you can use PhysX like an inverse dynamics solver.

    To set up your own rig with it:

    Set up the rig like a ragdoll with rigidbodies and joints. Link the first rigidbody to the base that is a kinematic rigidbody and link the last to the target that is also a kinematic rigidbody and that will be your end effector. Then add InverseDynamics.cs to the root of the rig.

    You can also add colliders if you need to and ajust the mass of the Rigidbodies to adjust which part should move more or less.

    I've managed to use it to solve surgical lights, UR5, KUKA and some other complex stuff. Doesn't work well with humans though.

    Best,

    Pärtel
     
  24. valentin_bourdon

    valentin_bourdon

    Joined:
    Sep 17, 2015
    Posts:
    9

    Thanks a lot ! I will try it with the Kinova robot.

    Best,
    Valentin
     
    Last edited: Jan 7, 2019
  25. valentin_bourdon

    valentin_bourdon

    Joined:
    Sep 17, 2015
    Posts:
    9

    Hi Partel,

    Your example works perfectly for my stuff. The only problem is the rotation. It work but at a moment the rotation continue and my robot arm begin to vibrating and the movement/articulation is not physical possible.
    Have you ever had this problem ?
     
  26. prisonerjohn

    prisonerjohn

    Joined:
    Jul 31, 2013
    Posts:
    23
    Hello,

    I'm encountering an issue with the `LookAtIK` script where my model is looking the opposite way of the target. When I move left it looks right, when I move up it looks down, ... I posted a screen capture to show the issue here: https://drive.google.com/open?id=19MNBQztG7BAIj49QoNLtI77K06V3PE0U

    The same script applied to the example biped dummy is working properly in that scene, so I'm guessing there's some orientation issue with my model, I'm just new to IK and rigging and not sure what exactly the issue is and how to resolve it.

    I'd really appreciate any suggestions, thanks in advance!
     
  27. shubhank008

    shubhank008

    Joined:
    Apr 3, 2014
    Posts:
    59
    1. I have a Oculus Rift, can I test/develop using IKVR and my oculus and it will work as it is for Vive/SteamVR too ? Or do I need vive as well to create cross-compatible IK.
    2. Is the IKVR compatible with PSVR too ? Atleast the head tracking I mean.
    3. Is there any limitation on body/character size ? Like there are normal human mixamo charas and there are human midgets or dwarfs or such from cgtrader or assetstore.
     
  28. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Hey,
    If you could export a unityPackage of that scene with the rig set up, also include the fbx and let me know which Unity version you used, I'd be happy to take a look.

    Hey,

    LookAtIK samples the rotation of the head and other bones relative to the rotation of the gameobject when it initiates to find out which axes of the bones are supposed to look forward.

    So you should have LookAtIK on the root of the character (or on a child gameobject with zero localRotation), the character facing towards the positive Z axis of the root.

    Hey,
    1. You should get a Vive. I mean you could add in SteamVR utilities and develop in blind and hope it all will just work, but it never does.
    2. Yes.
    3. No limitation there. Only the "Min Head Height" value in VRIK spine settings needs to be adjusted if you are working on a dwarf.

    Cheers,
    Pärtel
     
    prisonerjohn likes this.
  29. shubhank008

    shubhank008

    Joined:
    Apr 3, 2014
    Posts:
    59
    Thanks. Vive seems a bit out of reach for now as recently got a oculus and planning to get a WMR too, so will hold on that or just borrow someone's Vive. Really glad to know it works for PSVR and different body/heights too.
    Do you know of any upcoming sale coming up ? I got a lot of assets during the black friday sale and now feel like a idiot having FinalIK in wishlist but not getting it during those 50% sales.
     
  30. chilton

    chilton

    Joined:
    May 6, 2008
    Posts:
    473
    Hi,

    How do I tell VRIK to 'recenter' the legs under the torso? I have characters that can move *just* enough to look awkward, and I'd like to just have the legs move to a more natural position after a few seconds. I can handle the time part, I want to know how to tell VRIK to shuffle those legs.

    Screen Shot 2019-01-10 at 1.36.19 PM.png

    -Chilton
     
  31. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Hey,
    I don't know when the next sale is, but FIK is included in sales quite often so it's not gonna be too long. Its also 33% off in the Ultimate Characters Bundle.

    Hey,
    Seems like way too much lean there, what kind of settings do you have under locomotion?
    You could set ik.solver.locomotion.stepThreshold to 0 for a frame to force it to take a step.

    Best,
    Pärtel
     
  32. mgwade528

    mgwade528

    Joined:
    Apr 24, 2017
    Posts:
    7
    Hi,
    I have htc vive,and using VRIK to test.now i have a problem, except for T-Pose any movements can cause the shoulders will droop,the shoulder shrug is not good looking.
    in rig humanoid mode i adjust the angle of the shoulder ,but in play mode not change as before.
    is the angle of the shoulder according to the arm?what should i pay attention to?
     
  33. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Hey,
    Please go to IKSolverVRArm.cs and change
    Code (CSharp):
    1. private const float pitchOffsetAngle = -30f;
    on line 155 to -40 or something like that, or just make it public so you could tweak it in the Editor.
     
  34. prisonerjohn

    prisonerjohn

    Joined:
    Jul 31, 2013
    Posts:
    23
    Amazing! I just rotated the root 180 degrees and it's now working properly. Thanks for your help.
     
  35. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    583
    Is there something that can be used to animate a non human flesh turret destruction? What I want to achieve is, that the bones fall to the terrain. I could give each bone a sphere collider and a rigidbody (or use raycast) to let the bones fall to the terrain at destruction. But more controlled ragdoll would be better, because the distance of the bones defines the mesh size, that I couldn't control with this solution (maybe with well sized collider).
    I use for the finger AimIK.

    FleshTurret.jpg
     
  36. Bamfax

    Bamfax

    Joined:
    Jun 12, 2016
    Posts:
    51
    Using 2018.3 and FinalIK 1.8, my project suddenly started to revert back my custom script execution order of AimIK. I never had that happen before in the last months, but now on every change I do to the script execution order of AimIK, it reverts back to default order. Is there some Editor Component in FinalIK that does that?
    Thanks for your help.

    Edit: Ok, found it. IKInspector and AimIKInspector are doing it. Pärtel, would you be so kind, if there isn't one yet, to introduce a toggle which would allow us to customize the script execution order?
     
    Last edited: Jan 13, 2019
  37. teighshiclbw

    teighshiclbw

    Joined:
    Jun 26, 2018
    Posts:
    34
    Hi Partel
    I am using AimIK to make weapon aim to target point, but when character look up, his spine always bend too much
    Idle Look up(Spine bones rotate up)
    The requiment is:
    Character look up, spine won't rotate up
    Character look down, spine rotate down
    Character look left, spine rotate left
    Character look right, spine rotate right

    What is the correct way to achieve this goal?
    I try Rotation Limit Polygonal,

    When character look up, his spine won't rotate up, that's what I want indeed.
    But it also limit rotation from animation, idle animation rotate spine a little bit to make character looks like breathing, which is needed,
    But after adding Rotation Limit Polygonal to spine, character won't breath because bone rotation has been limited.
    So I need rotation from animation, but I don't need up rotation from AimIK(I need down, left, right rotation though).
    Is this possible? How do I achieve this?
    Many thanks!
     
  38. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Hey,
    There's no specific tool for that, sorry. You'd need to cut up the skinning to individual parts so it could be cut. Not a job for inverse kinematics.

    Hey,
    The problem with that, if everybody had their own custom update order, it would soon become very difficult for me to find bugs in your projects or reproduce them based on desciptions. If you need custom update order, please use the IKExecutionOrder component or disable the IK components in Start and call ik.solver.Update() in whichever order you please.

    Hey,
    The RotationLimits get their default localRotations when they initiate, so they will limit the rotation based on that. With animated characters you should update the default localRotations in each LateUpdate, after the animation:

    Code (CSharp):
    1. public RotationLimit[] limits;
    2.  
    3. void LateUpdate() {
    4. foreach (RotationLimit limit in limits) {
    5. limit.SetDefaultLocalRotation();
    6. }
    7. }
    Best,
    Pärtel
     
  39. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    583
    Thanks for your answer. Maybe I have to replace the turret with a fractured mesh. For now I let fall one bone...

    bandicam 2019-01-14 19-28-50-423.jpg
     
  40. teighshiclbw

    teighshiclbw

    Joined:
    Jun 26, 2018
    Posts:
    34
    This works!
    MANY THANKS!
     
  41. marvalshot

    marvalshot

    Joined:
    Dec 29, 2013
    Posts:
    155
    Not directly final ik question but what is the best programming practice for working with multiple animations on one game object where they each have different effector, targets, bones, pins etc... Right now my code is a mess because I keep swapping out everything instead of just setting the inspector.. I don't think it's a good idea to add ie 12 ik component sets for 12 animations?
     
  42. ProtoPottyGames

    ProtoPottyGames

    Joined:
    Dec 18, 2015
    Posts:
    43
    Are you looking to make the skinned parts actually detach? If so then yes, you will need to do as Partel suggested and either "pre-cut" the mesh in a 3D app and then unparent the segments on Die(), or use a system that's designed to split meshes in realtime (like Limb Hacker or something. It's free fyi. ;) ). However If you'd just like it to fall loose and flop around when it's dead, you can create a custom ragdoll using character joints and colliders in Unity. There are tutorials around explaining each of these methods if you google around a bit.
     
    Partel-Lang likes this.
  43. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Hey,
    I'd make a new serializable class like "IKState" or something that holds an animation state name and all the IK values that you need to modify. Then make an array of it: public IKState[] ikStates; and fill it in in the Editor. Then you just need to add an Apply() method to that class that applies all the IK params and call Apply() on the state that's animation state name matches the currently playing animation.

    Another similar way to do this, might be even easier, would be to make a IKState extend from StateMachineBehaviour. Then you can add it to each animation state directly in the Animator Controller and use OnStateEnter to apply the IK parameters.

    Will be a bit more complicated if you need to smooth-blend every parameter, but the basic idea is the same.

    Cheers,
    Pärtel
     
    marvalshot likes this.
  44. marvalshot

    marvalshot

    Joined:
    Dec 29, 2013
    Posts:
    155
    Thank you.. Next. . Maybe newbie question... Trying to understand when working with fbbik and aim together.. In my case kick boxing combat what should be updating first and when and why???.. Also any other general tips for this type of setup.. I read all the docs and scripts and watched all the videos about 172000 times but it's just not registering for me much.. Arggg.. Thanks for the great asset and support though.

    Add to this one example.. In boxing demo you update aimik but not fbbik but no idea why.
     
  45. tcmeric

    tcmeric

    Joined:
    Dec 21, 2016
    Posts:
    181
    Hi, I searched around the forum here is this is what I came up with.

    I am using. AIM IK + Full Body IK (No look). Aim IK is solving for the right arm only (no spine/ neck, etc).

    Using it for FPS arms. I am using a custom shoot animation.

    I am having two problems.

    1.

    After each shot, (shoot animation is played), the left hand becomes a little less in the correct position. After several shots, it is completely off. I can solve this in the editor, by turning on and off the Aim IK script. Then the left hand returns to the correct position.

    2.

    When my SecondHandOnGun script is enabled, the hips (and all its children such as the hands) keep rising in the scene. I dont think its an animation problem, as it only happens when this script is enabled.

    EDIT: If I enable manually the FullBodyIK script from the inspector, the hips (therefore hands), stop rising as well. Also the hands return to the correct position.

    Here is my script. Thank you!

    Code (CSharp):
    1. using UnityEngine;
    2. using RootMotion.FinalIK;
    3.  
    4. public class SecondHandOnGun : MonoBehaviour
    5. {
    6.     // References to the IK components
    7.     public AimIK aim;
    8.     public FullBodyBipedIK ik;
    9.     public Transform target;
    10.     private Vector3 toLeftHandRelative;
    11.  
    12.  
    13.     // Just quick shortcuts to the hand effectors for better readability
    14.     private IKEffector leftHand
    15.     {
    16.         get { return ik.solver.leftHandEffector; }
    17.     }
    18.  
    19.     private IKEffector rightHand
    20.     {
    21.         get { return ik.solver.rightHandEffector; }
    22.     }
    23.  
    24.     private Quaternion leftHandRotationRelative;
    25.  
    26.     void Start()
    27.     {
    28.         // Disabling (and initiating) the IK components
    29.         aim.enabled = false;
    30.         ik.enabled = false;
    31.  
    32.         ik.solver.OnPostUpdate += OnPostFBBIK; // Add to the OnPostUpdate delegate of the FBBIK solver
    33.     }
    34.  
    35.     void LateUpdate()
    36.     {
    37.         Read();
    38.         AimIK();
    39.         LeftHandPosition();
    40.         PinRightHand();
    41.  
    42.         // Update FBBIK
    43.         ik.solver.Update();
    44.     }
    45.  
    46.     private void PinRightHand()
    47.     {
    48.         // Making sure the right hand won't budge during solving
    49.         rightHand.position = rightHand.bone.position;
    50.         rightHand.positionWeight = 1f;
    51.         ik.solver.GetLimbMapping(FullBodyBipedChain.RightArm).maintainRotationWeight = 1f;
    52.     }
    53.  
    54.     private void LeftHandPosition()
    55.     {
    56.         // Position the left hand on the gun
    57.         leftHand.position = rightHand.bone.TransformPoint(toLeftHandRelative);
    58.         leftHand.positionWeight = 1f;
    59.     }
    60.  
    61.     private void AimIK()
    62.     {
    63.         // Set AimIK target position and update
    64.         aim.solver.IKPosition = target.transform.position;
    65.         aim.solver.Update(); // Update AimIK
    66.     }
    67.  
    68.     // Rotate the left hand after FBBIK has finished, called by the FBBIK solver
    69.     private void OnPostFBBIK()
    70.     {
    71.         leftHand.bone.rotation = rightHand.bone.rotation * leftHandRotationRelative;
    72.     }
    73.  
    74.     private void Read()
    75.     {
    76.         // Find out how the left hand is positioned relative to the right hand rotation
    77.         toLeftHandRelative = rightHand.bone.InverseTransformPoint(leftHand.bone.position);
    78.         // Rotation of the left hand relative to the rotation of the right hand
    79.         leftHandRotationRelative = Quaternion.Inverse(rightHand.bone.rotation) * leftHand.bone.rotation;
    80.     }
    81. }
    handIK.png
     
    Last edited: Jan 19, 2019
  46. WJYxsj

    WJYxsj

    Joined:
    Nov 12, 2018
    Posts:
    1
    Hi,I am using VRIK. I noticed that the model's hand is straight and stiff. Can I modify some of the code so that the hand can keep a little natural bending in the straight state?
     
  47. iklw1115

    iklw1115

    Joined:
    Nov 14, 2018
    Posts:
    15
    Hi,
    Can you display and manipulate only a part of the body of the model?
    I tried variously changing the scale, but I am getting rid of it because the position of the HMD does not match the position of the head.
     
  48. a-t-hellboy

    a-t-hellboy

    Joined:
    Dec 6, 2013
    Posts:
    148
    Hey Partel,

    I want my character left hand hold the weapon correctly so I use left hand effector on FBBIK.

    Capture.PNG

    As I read, Rotation Weight doesn't work correctly (Also I've tested and seen it doesn't work correctly)

    So I wrote this piece of code for hand rotation.

    Code (CSharp):
    1.     private FullBodyBipedIK ik;
    2.     private IKEffector leftHandEffector { get { return ik.solver.leftHandEffector; } }
    3.  
    4.     void Awake()
    5.     {
    6.         ik = GetComponent<FullBodyBipedIK>();
    7.     }
    8.  
    9.     void Start()
    10.     {
    11.         ik.enabled = false;
    12.     }
    13.  
    14.     void LateUpdate()
    15.     {
    16.         leftHandEffector.bone.rotation = leftHandEffector.target.rotation;
    17.         ik.solver.Update();
    18.     }
    But unfortunately it look like this (Wrist doesn't look good)

    Capture2.PNG

    No rotation:

    Capture3.PNG

    What should I do to prevent this ?
     
  49. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Hey,
    In the boxing demo FBBIK is updated as the component is enabled, so it updates. I just don't need to change any of it's parameters or targets by script. In that demo, AimIK updates before FBBIK (as it normally does by default, see the Script Execution Order). So AimIK is used to make the character spine turn towards the target to make things a bit easier for FBBIK. Then FBBIK updates to make the fist reach the target exactly. If you don't need 100% accuracy like that, I suggest you check out the "Aim Boxing" demo instead. That only does AimIK to reorient the attack animation towards the target.

    Hey,
    Add this:
    Code (CSharp):
    1. void Update() {
    2. ik.solver.FixTransforms();
    3. // also aim.solver.FixTransforms(); if the above doesn't do the trick.
    4. }
    Thing is, if IK components are disabled and updated manually, FixTransforms() needs to be called manually too. It will move the character to its default pose, so there will be no additive effects if any of the bone rotations are not overwritten by animation.

    Hey,
    You can use the automatic stretching feature. Please go to the "VRIK (Basic)" demo and copy the "Stretch Curve" over from the Pilot's arm settigns to your own avatar.

    Hey,
    You can use the "Arm Length Mlp" or "Leg Length Mlp" to change the proportions of the limbs if that's what you meant. If you need to scale the entire avatar, you can do so by scaling the root. Might need to adjust the localPosition of the head target if the HMD ends up off.

    Hey,
    If you rotate the hand bone directly in LateUpdate, you'll need to set "Maintain Hand Rot" to 1 in the arm settings of FBBIK. Otherwise you set the rotation, but it will be offset as the solver rotates the arm to reach the target position.

    Best,
    Pärtel
     
    tcmeric likes this.
  50. a-t-hellboy

    a-t-hellboy

    Joined:
    Dec 6, 2013
    Posts:
    148
    I didn't understand what exactly you mean. By setting "Maintain Hand Rot" to 0, wrist doesn't still look good.