Search Unity

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

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

  1. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hey,
    Here's the last integration I had with LeapMotion (Orion).

    You might also want to try this FingerMapping tool. You might be able to use it to rotate the avatar's fingers to match the LeapMotion rig's fingers. It only does the fingers though, so you'll need LimbIK or VRIK to do the arms and hands, assign that IK component into the "IK" slot in FingerMapping. "From To Rotation" mode does 2DOF matching, basically just swinging each finger bone towards the next target bone. "Match Rotation" mode does full 3DOF (rotational) matching. Forward and Up axes define bone orientations for the avatar and Leap rig's fingers. Forward is the local axis pointing towards the next bone and Up is the local axis that would point up if you held your hand flat on a table.

    Best,
    Pärtel
     
    Octarina likes this.
  2. Khang_Pham

    Khang_Pham

    Joined:
    Feb 28, 2021
    Posts:
    13
    Hi, I am working on the same topic,
    may I ask where would you have to insert this code for it to work?

    I have a script to set parameters in my blend tree for the walking animations, but when I set the weight of the VRIK locomotion to 0 the legs stay stationary. If I set it to 1, it overwrites my blend tree.
    If I understand correctly this script should fix it?
    But where do I have to insert it?

    Or is there perhaps some documentation on how to use a blend tree for walking animations in combination with VRIK?
    Your help is much appreciated!
     
  3. Khang_Pham

    Khang_Pham

    Joined:
    Feb 28, 2021
    Posts:
    13
    To elaborate:
    I do understand this apporach you have:
    "Hi!
    The intended way is to use procedural locomotion with roomscale movement. Blend locomotion weight to 0 if you are doing some movement that is not the real movement of the player, but based on some button input or whatever. Then if the player stops, call vrik.solver.Reset(), blend back in. I'm planning to improve procedural roomscale locomotion in the future.."

    But when the blend locomotion weight is 0, the character lower body is glued to the floor until the reset...
    I tried writing a custom script to anchor the character to my VR cam, but that comes with a bunch of different problems.
    Is there an official solution for this?

    Thanks!
     
  4. Kagyu

    Kagyu

    Joined:
    Mar 5, 2016
    Posts:
    96
    Hi Partel,
    I am struggling about making bend goals work properly.
    I added FBBIK and effectors to my avatar in runtime and the head effector, hand effectors and foot effectors work just perfect but only bend goals for arms and legs chain do not work right.

    For example, as I increase left arm's bend goal weight, the elbow goes away from the target and becomes kind of static.
    I think I need to perform some kind of initialization after adding targets to bend goals but I could not find proper information regarding the process from the manual such as here.

    I am adding bend goals like below
    Code (CSharp):
    1.     public Transform AddLeftElbowEffector(GameObject go)
    2.     {
    3.         Transform target = new GameObject().transform;
    4.         target.name = $"LeftElbowEffector({go.name})";
    5.  
    6.         FullBodyBipedIK fbbik = go.GetComponent<FullBodyBipedIK>();
    7.         fbbik.solver.leftArmChain.bendConstraint.bendGoal = target;
    8.  
    9.         return target;
    10.     }
    What else do I need to make them work right?
    BTW, fbbik and all effectors including bend goals works perfect when I add them in the Editor before hit play, of course.
     
  5. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hey,
    If you set locomotion weight to 0 and the legs stay stationary even with walking animation playing, then there can be exactly 3 causes for that:

    1) Position and Rotation Weight is set to 1 in VRIK leg settings
    2) Animator is disabled
    3) If the legs are moving as if they're walking, but the root of the character is not following, you probably have "Apply Root Motion" disabled in Animator.

    Here's an example package about animated locomotion. It uses root motion and a bit of code to drive the animation parameters.

    Hey,
    I tried to setup FBBIK at runtime and add Bend Goal by script here, didn't notice any issues.
    But I did notice this thin cyan line from the elbow to the right knee in the video:
    LeftBendGoal.JPG
    That line is drawn by FBBIK from the elbow to it's bend goal, so I think the problem is that the bend goal is not actually where that elbow handle is. Also you seem to have 4 gameobjects named "LeftElbowEffector..." so I think your script is creating bend goals for all limbs, but only assigning them to the left arm's bend constraint.

    Best,
    Pärtel
     
    Khang_Pham likes this.
  6. Kagyu

    Kagyu

    Joined:
    Mar 5, 2016
    Posts:
    96
    Partel,

    Thank you so much for your advise. That was it and now all effectors work right!
    Feel a bit bad for taking you time for my stupid mistake...
     
  7. ynm11

    ynm11

    Joined:
    Jul 6, 2021
    Posts:
    57
    Hi,
    I put a FBBIK on my character.
    I did a script where I set the LeftHandEffector Target to the transform.position of a randomly placed object in my game.
    Worked great.

    HOWEVER... When I erased the code in my script that would set the LeftHandEffector target, the game kept behaving as if the Target was active. I even removed the Script from the Player entirely... but the Player was still reaching for something, even though no script should be telling Player to do that.

    Do FBBIK Effectors have, for lack of better term, a 'memory' of the most recent Target you set them as?
    Or am I probably just doing something wrong and not realizing?
    Thanks.

    EDIT:
    Apologies. I had Position Weight set to 1 in the Inspector, and I think it is actually just normal behavior for a "(None) Target" to still change your character's pose if you have Weight turned up in Inspector. So this is normal behavior and has nothing to do with Final IK "remembering" the last target I gave it!
     
    Last edited: Jul 7, 2021
  8. HAIRGROW

    HAIRGROW

    Joined:
    May 17, 2013
    Posts:
    19
    Hi Partel,

    I've created a pause menu using Time.timeScale = 0;, but how can I ignore the time scale when using VRIK? I noticed the limbs won't move if the Time Scale is set to 0. I'd like to allow the player avatar to continue moving while using the Pause Menu.
     
  9. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hey,
    VRIK is "timeless" for the most part, it is only the built-in locomotion module that is temporal. So the IK should work with 0 time scale, just not the locomotion. If you don't see hands moving, it must be something other than the IK that stops.

    To make VRIK locomotion work with 0 time scale, would have to open these files:

    IKSolverVR.cs
    IKSolverVRLocomotion.cs
    IKSolverVRFootstep.cs

    Find all "Time.deltaTime"-s in them and replace with "Time.unscaledDeltaTime".

    Best,
    Pärtel
     
  10. HAIRGROW

    HAIRGROW

    Joined:
    May 17, 2013
    Posts:
    19

    Hey thanks for the response Partel. I didn't think about the hierarchy in my rig setup. I'm using Auto Hand which follows the players controller transforms, while the VRIK Target transforms follow the Auto Hands. With this set up, the Players Hands and Arms react to wall / object collisions. So if VRIK is "timeless" then that makes sense the hands would be frozen because of the Auto Hand plugin. I'll reach out to that developer. Thanks.
     
  11. PhilFaily

    PhilFaily

    Joined:
    Jul 31, 2017
    Posts:
    13
    Hi Partel!

    Quick Question...

    I have a working AimIK system going but I want to add FBBIK HitReactions as well.

    Is there any issue with adding the FBBIK Component as well as the AimIK & LookIK in the same system?

    What would I need to be aware of given they all have different Weights and for the AimIK/LookIK I am call their updates manually to ensure execution order.

    Would be good if the HitReaction demo used AimIK as well since the character is holding a gun.
     
  12. jimmygladfelter

    jimmygladfelter

    Joined:
    May 3, 2020
    Posts:
    83
    Hello All!

    I am pretty new to IK in general, please excuse me if this is a dumb question:
    I was wondering if Final IK grounder has an easy way to detect which foot is grounded at any given time?

    The reason was I was going to rely on it for other purposes like which leg to jump from etc.
    If not, I have other ways of knowing via independent IK goals in OnAnimatorIk.
     
  13. Partel-Lang

    Partel-Lang

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

    Yes, you can use AimIK together with FBBIK and HitReaction. Just add AimIK to that demo character, setup the bones to use, Aim Transform and done. AimIK updates before FBBIK so it just aims the gun and all the hit reaction stuff will run additively on top of that. You can add LookAtIK to it too, but LookAtIK normally updates after AimIK. If LookAtIK uses any spine bones, that will make the aiming inaccurate, so better to make LookAtIK update before AimIK in that case. Add the IKExecutionOrder component and assign the IK components in this order:

    LookAtIK
    AimIK
    FullBodyBipedIK

    Hey,
    No, Grounder doesn't actually know which foot is planted at all. It doesn't need to, it just vertically warps the animation to the terrain.

    But if it's a Humanoid, you can simply use Animator.pivotWeight. For a value of 0, the left foot is the most stable point. For a value of 1, the right foot is the most stable point. So if (animator.pivotWeight > 0.5f) { jump from right foot } else { jump from left foot };

    Best,
    Pärtel
     
  14. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    507
    Thanks you. But it doesn't fix the problem totally! Animation still looks weird also other custom animations like talking and walking still looks bad root motion doesn't work normally yet and only works normal by removing "Character Animation Third Person Ik" script :eek:

    Also Animator Match Target can't work normally too.
     
    Last edited: Jul 17, 2021
  15. rk_zgb

    rk_zgb

    Joined:
    Jun 15, 2021
    Posts:
    1
    Hi people!
    i'm new to unity and Final IK, i need to animate Quadruped animal that i made in Blender to walk in unity scene. Problem is that i can't get it working properly. Animal is walking towards the destination cube, but its falling through the ground and on the head. Can anyone find what i'm doing wrong? I followed this tutorial

    And this are the settings inside unity for final ik.

    ps. Is there any kind on newer video tutorial about Quadruped animals step by steps?

    R.
     

    Attached Files:

  16. Octarina

    Octarina

    Joined:
    Oct 4, 2019
    Posts:
    8

    Thanks you very much, it works has i expected in terms of tracking and matching on the avatar in VR and leap motion DESKTOP set up. The version you provided us is using the leap motion in the desktop mode.
    The point is I need to use the Leap motion in the ‘VR headset’ mode

    Could you tell me how to proceed, please?
     
    Last edited: Jul 21, 2021
  17. unitydreamer29

    unitydreamer29

    Joined:
    Dec 27, 2020
    Posts:
    47
    Hi Partel,

    Using FinalIK with VRIK_PUN_Player.cs with PUN2. On my local instance, IK looks great and is smooth. On the remote instance, the player is slightly bouncing up and down, and the pelvis is moving back and forth. The feet remain planted. Any ideas on how to improve this?

    Thanks!
     
  18. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hey, sorry for the wait. Tested with some more animations, please try importing this.

    Hey,
    When you select the root of the animal as it moves, does it follow terrain height?

    Hey,
    I'm not sure how, sorry, my leap device broke down years ago so can't really test it here either.

    Hey, I tried that PUN2 demo again, but didn't see anything weird like that. Would it be possible for you to record a video please? Maybe I can spot something from there.

    Best,
    Pärtel
     
    Crossway likes this.
  19. Mister-D

    Mister-D

    Joined:
    Dec 6, 2011
    Posts:
    1,694
    im trying to have the "lookat IK" look at a point in front/side of a car, based on the cars' direction/velocity,
    but i cant figure it out. i dont want to use a" target" transform, so im trying to set the "IKposition". but i cant figure out how to calculate the position.
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using RootMotion.FinalIK;
    5. public class CarPlayerLookAt : MonoBehaviour
    6. {
    7.     public LookAtIK look;
    8.  
    9.     public Transform Rootpivot;
    10.     Vector3 lookdirection;
    11.     public float addheight = 1f;
    12.     public float addDepth = 1f;
    13.     //Vector3 startpos = Vector3.zero;
    14.     private Transform reference;
    15.     private SCC_Inputs inputs;
    16.  
    17.     void Awake()
    18.     {
    19.         reference = new GameObject().transform;
    20.     }
    21.     void Start()
    22.     {
    23.  
    24.         inputs = Rootpivot.GetComponent<SCC_Inputs>();
    25.  
    26.     }
    27.     void LateUpdate()
    28.     {
    29.         if (!inputs)
    30.         {
    31.             enabled = false;
    32.             return;
    33.         }
    34.      
    35.  
    36.         reference.eulerAngles = new Vector3(0, Rootpivot.eulerAngles.y, 0);
    37.      
    38.         Vector3 forward = reference.forward;
    39.         forward = transform.InverseTransformDirection(forward);
    40.         Vector3 right = new Vector3(forward.z, 0, -forward.x);
    41.  
    42.         right = transform.InverseTransformDirection(right);
    43.  
    44.         //input
    45.         Vector3 wantedlookdirection = (inputs.steering * right);
    46.         //wantedlookdirection = wantedlookdirection.normalized;
    47.  
    48.  
    49.  
    50.  
    51.  
    52.  
    53.  
    54.  
    55.         lookdirection = wantedlookdirection  + Rootpivot.position;
    56.         lookdirection.z += addDepth;
    57.  
    58.  
    59.         look.solver.IKPosition = lookdirection;
    60.         look.solver.Update();
    61.         Debug.Log(lookdirection);
    62.     }
    63. }
    isnt there a way to set a direction instead of a position to look at?
     
    Last edited: Jul 27, 2021
  20. Partel-Lang

    Partel-Lang

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

    Something like:

    Code (CSharp):
    1. look.solver.IKposition = car.position + Quaternion.AngleAxis(lookAngle, Vector3.up) * car.forward * 10f;
    Best,
    Pärtel
     
  21. Mister-D

    Mister-D

    Joined:
    Dec 6, 2011
    Posts:
    1,694
    works perfect! tnx!
     
  22. Mister-D

    Mister-D

    Joined:
    Dec 6, 2011
    Posts:
    1,694
    tnx for your help and plugin
    made my driver fully procedural with biped ik and lookat
     
  23. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Awesome! Agent 47 in Mad Max world? :cool:
     
    Mister-D likes this.
  24. giraffe1

    giraffe1

    Joined:
    Nov 1, 2014
    Posts:
    302
    What is the easiest way and most performant way to achieve leaning for my NPC's with FinalIK?

    Is using the AimIK component with a pole target the best way?

    If so, is having multiple AimIK Components a problem? Currently I am using an AimIK component in conjunction with the secondHandOnGun script to handle aiming but I am not sure if I can just add a second AimIK component and do my leaning logic on it or if I should try to recycle the AimIK component I am currently using (for aiming) and write a bit of if/else logic to allow me to dual purpose it for leaning and aiming.

    Currently I am using the Animation Rigging package with the multi-rotation constraint to achieve these results:


    I am trying to achieve this with Final IK.

    Thanks!
     
  25. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hey,
    With AimIK you can do that kind of leaning using the Pole Target. Set Pole Axis to be the local axis of the Aim Transform that is pointing up normally. Set Pole Weight to 1, create a gameobject to be assigned as the Pole Target. Parent that gameobject to the character root, move it above the character's head. Then you can lean left/right by moving that pole target left/right.

    If you don't like that pole target stuff and would rather have just an angle parameter for leaning left/right, you can use this little script:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class LeanController : MonoBehaviour {
    6.  
    7.     [System.Serializable]
    8.     public class Bone
    9.     {
    10.         public Transform transform;
    11.         [Range(0f, 1f)] public float weight = 1f;
    12.     }
    13.  
    14.     [Tooltip("Bones used for leaning (spine).")] public Bone[] bones = new Bone[0];
    15.     [Tooltip("Transform defining the rotation space. Normally this would be the root of the character.")] public Transform space;
    16.     [Tooltip("Local axis of the 'space' Transform to lean around.")] public Vector3 axis = Vector3.forward;
    17.     [Tooltip("The lean angle")] public float angle;
    18.  
    19.     private void LateUpdate()
    20.     {
    21.         if (bones.Length == 0) return;
    22.  
    23.         // Find rotation axis in world space
    24.         Vector3 axisWorld = space.rotation * axis;
    25.        
    26.         // Total weight of the bones divided by the number of bones
    27.         float weightSum = 0f;
    28.         foreach (Bone bone in bones)
    29.         {
    30.             weightSum += bone.weight;
    31.         }
    32.         weightSum /= (float)bones.Length;
    33.  
    34.         if (weightSum <= 0f) return;
    35.  
    36.         // Find the weighed rotation angle
    37.         float a = angle / (float)bones.Length;
    38.         a /= weightSum;
    39.  
    40.         // Rotate the bones
    41.         foreach (Bone bone in bones)
    42.         {
    43.             bone.transform.rotation = Quaternion.AngleAxis(a * bone.weight, axisWorld) * bone.transform.rotation;
    44.         }
    45.     }
    46. }
    47.  
    Add it to the character, assign the spine bones as Bones, set bone weights to 1, assign the root of the caracter as Space. Then play the scene and try changing 'angle'. AimIK can work on top of that too.

    There is no problem with using multiple AimIK components, you'll just have to mind their update order. For example if you have AimIK for weapon aiming, using spine and arm bones and another one for head look-at, using neck and head bone, you'll have to solve the weapon aiming one first. Can use IKExecutionOrder component for that.

    Cheers,
    Pärtel
     
    giraffe1 likes this.
  26. alex0317063

    alex0317063

    Joined:
    Jul 25, 2016
    Posts:
    2
    Hi, Pärtel
    Thank you for this fantastic plugin!
    Now using the VR IK to control my avatar.
    However, when I look down with an HMD helmet, the HeadOffset, which Head Target refers to, will not stay inside the avatar head.
    It will cause I can see through the avatar head and body.
    Do you have any idea to solve this problem? Thanks!




    P.S.
    The avatar's hip, feet, and knees are tied to fixed references on the chair because I need my avatar to be seated on the chair.

    Best regards,
    Alex
    VR IK - problem (1).jpg
    VR IK - problem (2).jpg VR IK - problem (3).jpg
     
  27. Deckard_89

    Deckard_89

    Joined:
    Feb 4, 2016
    Posts:
    316
    @Partel-Lang Hi,
    Could you advise on how to use the interaction system for a character to grab a cigarette from his own mouth? I have managed to get it to pick up the cig using the event on the interaction object, but his arm just passes right through his body, as though it doesn't "know" to follow a curve around to the mouth, if this makes sense.
     
  28. shanemt

    shanemt

    Joined:
    Mar 5, 2014
    Posts:
    23
    Hi, question about Aim IK. I'm trying to use aim ik for aiming my shield, but I get this behavior. I have the aim transform as the back of the hand behind the shield, with Spine bones 1-3 + neck. No matter what I do, I will still get the behavior occasionally, even if I tweak the settings all day long.



    I have the following fields on the system I made:
    AimIkEnableLerpSpeed
    AimIkDisableLerpSpeed
    DelayForEnable
    DelayForDisable
    I edited the values to make the effect more noticeable, but even with a ton of time trying to get the values just right, I still get the behavior seen occasionally. Any suggestions for how to enable the Aim IK more smoothly?
     
  29. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hi,
    That's likely fixed for the next version already, sent you a PM.

    Hey,
    The hand normally follows a direct line from where it's at to the target. That is what the Position Offset X/Y/Z weight curves are for in the InteractionObject. You could add a curve of "Position Offset Z" type to give some curve to the motion of the hand. Just like in the "Interaction" demo the "Button" object uses "Position Offset Y" to make the finger drop down to the button.

    Hey,
    It twitches like that AimIK is weighed in at the same time as the Animator is transitioning to the shield-in-front animation. When you are playing the normal shield-on-side animation and set AimIK weight to 1, you'll see that AimIK has to bend the spine quite a lot to get the shield pointing forward. That is the source of the twitch right there. AimIK weight is blending to 1, but animation transition is not done yet. So you could either wait for the transition to complete before weighing in AimIK or make AimIK work in additive offset mode using this bit of code:

    Code (CSharp):
    1. public AimIK ik;
    2.         [Tooltip("The direction in which the weapon is aimed in animation (in character space). Tweak this value to adjust the aiming.")] public Vector3 animatedAimDirection = Vector3.forward;
    3.  
    4.         void LateUpdate () {
    5.             ik.solver.axis = ik.solver.transform.InverseTransformVector(ik.transform.rotation * animatedAimDirection);
    6.         }
    Like in the "Aim Swing" demo.
    That would probably work best, you'll also be able to play shield hit animations without AimIK messing it up by forcing the shield to point at the target at all times.

    Best,
    Pärtel
     
    shanemt and Deckard_89 like this.
  30. JonBanana

    JonBanana

    Joined:
    Feb 5, 2014
    Posts:
    85
    Hi @Partel-Lang ,

    I try to use FBBIK to pose character (no any animation) , its working well but idont know how to add constraint to avoid not natural rotation. Is it possible to do it ?

    Maybe FABRIK is a better option , is it possible to control intermediate part of chain (like knee and elbow) if i use FABRIK to pose my character ?


    Thanks
     
    Last edited: Aug 12, 2021
  31. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hey,
    You could try this little script to enforce humanoid muscle limits on top of the FBBIK to avoid illegal angles.

    You can control knees and elbows with FBBIK too, there are Bend Goals (will bend the limb towards the object assigned) and set Bend Goal Weight to 1 in FBBIK limb settings.

    Best,
    Pärtel
     
  32. JonBanana

    JonBanana

    Joined:
    Feb 5, 2014
    Posts:
    85
    That script is awesome , i didnt know about humanPose and muscle limits that are integrated in unity, that the perfect option for my project
    thank a lot :)
     
    Partel-Lang likes this.
  33. JonBanana

    JonBanana

    Joined:
    Feb 5, 2014
    Posts:
    85
    Hi @Partel-Lang ,
    Is there a way on FBBIK to 'lock/pin' feet or hand in a way that moving the rest of body will not affect them,
    Ex: i pin the feet and when i move the hip, the calculation force the foot to stay on the target

    Thanks
     
  34. daedal

    daedal

    Joined:
    Dec 19, 2013
    Posts:
    31
    Hey @Partel-Lang,

    I'm noticing some odd behavior with ArmIK. If I have a character that starts out enabled in the scene, the ArmIK will work as expected. However, if I have a character that starts out disabled, or if I disable then enable that character, the ArmIK will no longer track the IK target perfectly. Also the arm will become more influenced by animations, making object holding quite a problem.

    Another way I can reproduce the same behavior is by calling SetChain on the ArmIK solver using the same bones.

    Do you know what might be causing this and how to avoid the problem?

    Thanks!
     
  35. Partel-Lang

    Partel-Lang

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

    You can use "Pull" for that. Set Pull to 1 for only the leg that you need to be planted and set it to 0 for all the other limbs, then the foot will stay locked to the foot effector target.

    Hey,
    Yeah, ArmIK and most other IK components sample the pose when they are initialized to find out which way to bend the limbs and stuff. So to have consistent behaviour with IK disabled by default, leave the component enabled on the character prefab, then disable it at Start (to allow it to initialize the same way every time). Then just re-enable it when you need to use it.

    Best,
    Pärtel
     
  36. JonBanana

    JonBanana

    Joined:
    Feb 5, 2014
    Posts:
    85
    Thanks for the support, its working well when i pull hands or feet but i dont suceed to make it work will moving hips or shoulder :
    i d like to lock hand or foot but keep knee and elbow ik when i move hips or shoulder.

    Is it possible ?
     
  37. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    No, sorry, it is just the nature of the IK algorithm that causes body and shoulder effectors to take priority over the hands and feet. But you could try instead of using the body effector, keep it's weights at 0 and just move the root of the character.

    Best,
    Pärtel
     
  38. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    Hello Pärtel,

    I'm having a hard time with what seemed an extremely simple thing.
    I'll try to make it short:
    No VR involved
    I'm using AimIk to only have the character to aim at a world space target (the target is simply a transform following mouse position with a raycast)
    This works very fine.

    In my project I have weapon bullets coming out of the canon transform of the weapon in the simplest way possible:
    Code (CSharp):
    1. spawnPosition = _canon.position;
    The issue I have is that once AimIk is enabled, the weapon canon position seem to not be impacted at all and keep the original position. So my bullets are always coming from the wrong position.

    I exaggerated the problem with AimIk enabled by rotating a little bit up the weapon so you can see better:

    this is when shooting straight (the transform gizmo here is the canon):
    upload_2021-8-27_2-14-3.png

    It's obvious when shooting down:
    upload_2021-8-27_2-14-32.png

    And this is the result with AimIk disabled:
    upload_2021-8-27_2-14-48.png

    So my question as you can guess:

    How can I get the transform position of my weapon?
    This is killing me because in editor I can see the transform gizmo of the canon at the proper place with correct rotation etc.
    I tried to disable "Fix Transform" as well without success

    I saw the aim controller demo but this is way too advanced for my needs as I just need the very simple setup I have here. I did try with the aim controller but I still couldn't use the regular code posted above

    Thanks in advance for your help
     
  39. giraffe1

    giraffe1

    Joined:
    Nov 1, 2014
    Posts:
    302
    *********************************** edit ***********************************

    I found an older response from you where you answer this question.

    https://forum.unity.com/threads/fin...d-ik-1-0-released.222685/page-19#post-1945598

    This does indeed fix it. I will experiment with this.

    Thank you.

    Hi,

    I have a question. Please see video. The shoot animation in conjunction with final ik is causing a lot of up and down motion. What is the recommended way to deal with this?

    I noticed when I used an aim transform higher in the bone hierarchy it does not cause the up/down motion but then the aim becomes unaligned.

    Thank you

     
    Last edited: Aug 27, 2021
  40. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hey,
    Please find this problem explained and answered here.

    Hey,
    The problem is that the recoil animation rotates the gun up, but AimIK normally tries to keep it aimed at the target at all times, so it has to rotate the spine bones down to compensate.
    You should make AimIK work in additive offset mode. By that I mean use this bit of code:

    Code (CSharp):
    1. public AimIK ik;
    2.         [Tooltip("The direction in which the weapon is aimed in animation (in character space). Tweak this value to adjust the aiming.")] public Vector3 animatedAimDirection = Vector3.forward;
    3.  
    4.         void LateUpdate () {
    5.             ik.solver.axis = ik.solver.transform.InverseTransformVector(ik.transform.rotation * animatedAimDirection);
    6.         }
    It basically tells AimIK the weapon is already aimed forward in whatever animation that is playing (even if it's actually not like in the middle of a recoil animation) and to just offset from that.

    If you add AimController (see the "Aim Controller") demo, you can enable it just by enabling "Use Animated Aim Direction" in it.
    If the aiming becomes inaccurate, that is because the gun is not aiming 100% in forward direction in the animation and you can fix it by tweaking the value of "Animated Aim Direction".

    Using that technique allows you to maintain the look and feel of all your recoil, reloading, equipping etc animations, also sword attacks and stuff like that (see the "Aim Swing" demo).

    Best,
    Pärtel
     
    giraffe1 likes this.
  41. BrianMLatimer

    BrianMLatimer

    Joined:
    Aug 24, 2021
    Posts:
    1
    Hi Pärtel,

    I'm looking to create a robot arm sort of thing, and have been having problems implementing my idea.

    I'm trying to make a robot arm that mimics the positioning of a VR controller (rotation and position), and my idea to create this solution was to have there be two targets, one where the "wrist" would be, (just a point directly behind the grab-able object) and one where the "claw" would be.
    The end goal would be to have a robot that can pick up, rotate, and move objects, all while having joints only move one rotation axis. So far, I've only seen IK examples that ignore the rotation of the target.

    For example, if there were 5 joints, the first three joints would find and track the position of the wrist, and the other two joints would track the claw, enabling the claw to rotate/reposition objects.
    I've tried to use some of your systems, but cannot find a cohesive solution to the two-target implementation.

    Using this package, I've created some sorts of robot arms trying to combine different IK systems, (like one IK system to the wrist, then another IK system from the wrist to the fingers) but they either glitch out, track poorly, or certain joints fail to rotate on one axis.
    upload_2021-8-30_16-32-38.png
    gif.gif
    This is a rough test of what I currently have using aimIK, where the blue sphere is the first target, and the yellow is the second target. (I assume aimIK isn't the best solution to a problem like this, but its the one that worked out the best so far)
    What I'd like to have is the blue sphere being tracked as well as the yellow.
    With the red arm/line to line up with the yellow target, aligned with the darker line like this:
    upload_2021-8-30_16-35-30.png
    With my current implementation, the yellow sphere isn't being intersected correctly when rotating, and also comes with tons of strange movements of the arm when moving the targets around. I think the problem has to do with me using two IK systems, and them interacting badly with each other. Everything up until the wrist works fine.

    So, my question is, is there somewhere in this package that would allow me to easily track two targets like I described? Or, if not, how would you go about implementing an IK system to track the target's rotation?

    Thanks!
     
    Last edited: Aug 30, 2021
  42. Michal_Stangel

    Michal_Stangel

    Joined:
    Apr 17, 2017
    Posts:
    151
    Hello Pärtel,

    I export character FBX from DAZ to Blender and then into Unity. And Blender messes knee rotations, so they bend opposite direction or to some random angle. I saw your video tutorial how to fix it so I open created character prefab and rotate knee in order to get blue arrow pointing forward. Problem is that blue arrow jumps on x-axis in quite a big steps and is almost impossible to make it pointing forward (I can demonstrate it in short video for better understanding).

    Is there some other way how to do it? Ideally through code I could put into my custom class for processing FBX.
     
  43. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hey,
    No, unfortunately Final IK is not final enough, solvers that can do that are mostly used in robotics and probably not performant enough for games, which is why I haven't made the effort to implement them. Hopefully Unity will add inverse dynamics soon to the Articulation Body system. In the meanwhile, I have this package that sets up a PhysX rig to work similar to an inverse dynamics solver, please check it out.

    Hey,
    Yes, you can just write knee.localRotation = Quaternion.Euler(0, 0, 1) in Start().
    Whether the 1 should be on the X, Y or Z axis depends on the bone orientations of the model. Might have to be -1 instead. The point is to have the knee rotated just 1 degree in the natural bending direction.

    Best,
    Pärtel
     
  44. PhilFaily

    PhilFaily

    Joined:
    Jul 31, 2017
    Posts:
    13
    [EDIT] Work worked out what this issue was, the elbows were 'stretched' out, the Log Warning and red squares were good clues, we just added 1 degree of rotation to fix that and its fine now. :)

    Hi Pärtel,

    When I move the Weight value of the FBBIK past 0.8, the hand with the Aim IK component miss aligns with the animation. Any Ideas?

    FYI: I am using an IKEO script to control the order of the components.
    - LookIK
    - AimIK
    - FBBIK

    I'm also using the HitReaction and Grounder Components.

    upload_2021-9-4_9-43-0.png upload_2021-9-4_9-43-12.png
    upload_2021-9-4_9-47-20.png upload_2021-9-4_9-47-37.png
     
    Last edited: Sep 4, 2021
    Partel-Lang likes this.
  45. takuyacebok

    takuyacebok

    Joined:
    Jun 12, 2021
    Posts:
    4
    Hi, I'm trying to attach a gameobject using parent constraint to one of the bones on my humanoid that's being driven with VRIK. It seems like 'Fix Transforms' is not letting the gameobject follow the transforms after the solver has happened. Disabling 'Fix Transforms' creates the usual problem of the character climbing to the sky, so I believe it's best to keep it on. Is there any way around it?
     
  46. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hey,
    The problem is that Unity constraints update before Final IK and there's no way to change when they update. You can change when FIK components are updated though if you disable the IK components in Start and call ik.solver.FixTransforms(); in Update and ik.solver.Update() in LateUpdate.
    Also, here's a custom parent constraint that runs after IK for you.

    Best,
    Pärtel
     
    Whatever560 and takuyacebok like this.
  47. cybie

    cybie

    Joined:
    Sep 17, 2010
    Posts:
    91
    Hi Partel,

    I am using Full Body Biped IK to adjust the pose of my character. I assign a transform (let's call this Handle transform) to the Body Effector, and I can drag this Handle around and the character's moved as it should. My question is how do I obtain the "neutral position" so I can return this Handle to a position as if IK is turned off? Is there I can obtain the animated position?

    Thanks
     
  48. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hey,
    You can just se effector position and rotation weight to 0, then it will have no effect no matter where it is.
    But to set it to the animated position/rotation:

    Code (CSharp):
    1. void LateUpdate() {
    2.     ik.solver.leftHandEffector.position = ik.solver.leftHandEffector.bone.position;
    3.     ik.solver.leftHandEffector.rotation = ik.solver.leftHandEffector.bone.rotation;
    4. }
    Best,
    Pärtel
     
    cybie likes this.
  49. Dmeowmixer

    Dmeowmixer

    Joined:
    Jan 25, 2015
    Posts:
    12
    Hi @Partel-Lang. We are using FinalIK/VRIK and Puppetmaster in our VR game with the Index + 3 vive trackers but are having some issues with the Calibration controller script I got from this thread.

    After loading the game with the trackers connected, we hit the calibration button for the VRIK Calibration Controller script. The feet trackers then appear to become untracked and both are set to the hip tracker.
    I inspected the VRIK values, and they are still set correctly, also the steam vr_tracked_object components maintain their correct input assignments. So it doesn't look like anything is being reassigned within Unity.

    Here is a video of the issue. WARNING The audio is loud, please turn off your audio.

    This is our setup below showing the targets for the steam vr_tracked_object assignments.
    upload_2021-9-14_22-4-22.png

    upload_2021-9-14_22-3-29.png

    upload_2021-9-14_22-3-21.png

    We did not perform any major modifications to the Calibration Controller script, do you have any idea what might be wrong here?


    Thank you.
     
  50. lockbox

    lockbox

    Joined:
    Feb 10, 2012
    Posts:
    519
    I purchased this Asset a while back and I'm finally getting around to using it. I'm sure you get this a lot, but this is one of the best assets in the store and you, sir, are a genius! It's just totally awesome! Thank you so much!!