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

    CloudyVR

    Joined:
    Mar 26, 2017
    Posts:
    715
    One possible way might be to call DontDestroyOnLoad() on your character so it will remain unchanged when switching scenes?

    Also as for the thinness of the arms, have you looked into using the provided TwistRelaxer scripts?
     
    Partel-Lang likes this.
  2. CherryEngine

    CherryEngine

    Joined:
    Sep 10, 2015
    Posts:
    19
    You can use VRTK_
    About TwistsRelaxer - Where I can find those scripts?

    Because of game architecture I can not use DontDestroyOnLoad() - that's why I'm asking for best possible solution :)
     
  3. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hey,
    It will be sufficient to keep the scale change consistent between the scenes as Trappist-1 kindly suggested.
    If you can't use DontDestroyOnLoad for some reason, you could write the scale to PlayerPrefs and make a script that scales the character to that in the beginning of each level.

    About the wrists, TwistRelaxer.cs should be part of the Final IK package. If it's not, please update to the latest.
     
  4. CherryEngine

    CherryEngine

    Joined:
    Sep 10, 2015
    Posts:
    19
    So the only thing that I should keep is scale of the character (transform) ?

    ps. TwistRelaxer works great!
     
    Last edited: Mar 21, 2018
  5. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Yes, as far as character height is the only thing you calibrate.
     
  6. HappySylveon

    HappySylveon

    Joined:
    Aug 10, 2017
    Posts:
    11
    Hi,

    Is it possible to combine LookAt IK and Rotation limit angle? I want the character's head to not turn looking backwards if the target object for LookAt is behind the player directly, so the head should not rotate a lot on the Z-Axis, I tried adding Rotation Limit (Angle) at the head component of the player but it had no effect.
     
  7. CloudyVR

    CloudyVR

    Joined:
    Mar 26, 2017
    Posts:
    715
    Not sure if this will help but I asked a similar question previously. I was able to attain the behavior I needed. Check out these posts:

    #2863
    and
    #2866
     
    Partel-Lang likes this.
  8. HappySylveon

    HappySylveon

    Joined:
    Aug 10, 2017
    Posts:
    11
    I have disabled the spine bending, its similar to your problem, but only the head alone is flipping vertically to face the object that is behind the character, couldn't get your solution to work, I still have the problem.

     
    Last edited: Mar 22, 2018
    CloudyVR likes this.
  9. HappySylveon

    HappySylveon

    Joined:
    Aug 10, 2017
    Posts:
    11
    Another question: What can I do if I want the Look At to turn the character head in a smooth way? Because I want to switch target at run time multiple times, it feels weird that the head instantly faces the new target. Also how can I clear the target? I tried setting the target to null but it continues to face the last target position.
     
  10. CloudyVR

    CloudyVR

    Joined:
    Mar 26, 2017
    Posts:
    715
    To smoothly transition between targets you could possibly use an empty gameobject that interpolates between two target gameobjects.
    -----
    I just took a crack at creating an example:



    TransitionTarget.cs
    Code (csharp):
    1. using UnityEngine;
    2. using RootMotion.FinalIK;
    3. using System.Collections;
    4.  
    5. public class TransitionTarget : MonoBehaviour {
    6.     /*This script is attached to the "red" cube as seen in the video  - but in practice, the red cube is simply just an empty gameobject placed somewhere in your scene*/
    7.     float transitionVal = 0;
    8.  
    9.     Transform target_Last;
    10.     public Transform target_Next;
    11.     public LookAtIK look;
    12.  
    13.     [Range (0.005f, 1.0f)]
    14.     public float rate = 1f;
    15.  
    16.     void OnValidate()
    17.     {
    18.         if (target_Next) {
    19.             LookAtNewTarget (target_Next);
    20.         }
    21.     }
    22.    
    23.     void LookAtNewTarget(Transform t) {
    24.         target_Next = t;
    25.         target_Last = target_Last ? target_Last : transform;
    26.         transform.position = target_Last.position;
    27.         look.solver.target = transform;
    28.         transitionVal = 0;
    29.         StartCoroutine (RunTransition ());
    30.     }
    31.  
    32.  
    33.     IEnumerator RunTransition() {
    34.         float x = 0f;
    35.         while (transitionVal <= 1) {
    36.             float y = 1+(-Mathf.Pow(((x*2)-1),2) ); //an offset parabolic function: https://www.google.com/search?safe=off&ei=yGW0Wr7uAqSIggeUl6HoAQ&q=y+%3D+1%2B%28-%28%28x*2%29-1%29%5E2+%29&oq=y+%3D+1%2B%28-%28%28x*2%29-1%29%5E2+%29&gs_l=psy-ab.3..0i7i30k1l3j0i30k1j0i5i30k1j0i8i30k1l5.4266.10081.0.12208.5.5.0.0.0.0.73.309.5.5.0..3..0...1.1.64.psy-ab..0.3.209...0i8i7i30k1.0.iJeF2wvmYmY
    37.             transform.position = Vector3.Lerp(target_Last.position, target_Next.position, transitionVal);
    38.  
    39.             x += Time.deltaTime * rate;
    40.             transitionVal += y;
    41.             yield return null;
    42.         }
    43.         look.solver.target = target_Next;
    44.         target_Next = null;
    45.     }
    46.  
    47. }
     
    Last edited: Mar 23, 2018
    Partel-Lang and HappySylveon like this.
  11. Ohhhglasses

    Ohhhglasses

    Joined:
    Jan 15, 2015
    Posts:
    2
    I'm hoping to achieve a really huge win here and I'm looking for some guidance. I believe the problem I'm having is one of local coordinates and local-scaled vector math. To set up the scene, I have 2 punches with the below hypothetical characteristics:
    Left jab - This punch ,when using LookAtIK such that the chest is aiming at the target's head, will naturally hit the target's right shoulder (visual left.)
    Right hook - This punch , will naturally hit the target's chest on the left side (visual right.)

    How might I accomplish the task of making these attacks hit any given location on the target's torso? I'm assuming I would need to first store the contact point of each attack so that I can do some math to compare the "Natural contact point" vs. the "Desired Contact Point" and then I would want to offset the LookAtIK position by that difference. In trying to accomplish this, I am having trouble figuring out how to even efficiently determine the contact points to store them in the first place, and I'm also having some trouble applying the offset, as it seems to just apply the offset in world coordinates, rather than relative to the attacker.

    I need these attacks to be pin point accurate for my application.

    Oh one other thing. Since I want to normally use the basic look at for my idle, adjusting the look at could cause a significant deviation of the head. Since I want the head to still be looking at the player during the attack, does it make sense to use two individual LookAtIk components, one that goes from the base of the spine up to the top of the spine (used for targeting punches) and then a 2nd one that goes up the neck to the head?
     
  12. Partel-Lang

    Partel-Lang

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

    LookAtIK algorithm does not support RotationLimits. But AimIK does and it also does a very similar thing to LookAtIK, so I suggest you replace that LookAtIK with AimIK. You'll also be able to use the Pole Target and about the smooth looking, I added a new component - AimController.cs to the latest version. It handles all things like that and some more automatically. I also have LookAtController developed in a similar way for LookAtIK for the next version, let me know if you'd need that right away.

    Hey,
    Please take a look at the "Aim Swing" and "Aim Boxing" demos about how to retarget fighting animations with AimIK. There's also the "Boxing" demo that adds FBBIK to it for pinpoint accuracy.

    About having 2 IK components, you can absolutely do so. You can have one LookAt/AimIK for the fighting purpose and another AimIK for the head, just need to make sure the head is updated last. IK needs to be updated in the same order as the bones that it is using are in the hierarchy. You can use the IKExecutionOrder component for that.

    Cheers,
    Pärtel
     
  13. AndrewJamesBowen

    AndrewJamesBowen

    Joined:
    Oct 10, 2013
    Posts:
    13
    Hey,

    I've imported the project, and wanted to play around with the models like in the videos.
    However, I can't even seem to select the same anchor points to move parts of the character around without breaking everything or it being ignored.

    For example
    - CCD IK, I hit play, go to Scene, select a chain, and it breaks it in half when I move it
    - Mech Spider, same thing, the leg detaches from the body
    - Aim Boxer, it completely ignores me when I move a transform, like a toe02

    Are there any basic tutorials out there for someone completely new to this?


    Cheers
     
  14. HappySylveon

    HappySylveon

    Joined:
    Aug 10, 2017
    Posts:
    11
    I wonder if you could help me with the following: I'm adding facing the camera direction LookAt IK, the character's head would face where the camera is pointing at, so far the code is the following:

    Code (CSharp):
    1. private void CameraFacing()
    2.     {
    3.         Vector3 FacingDirection = ThirdPersonCamera.transform.position + ThirdPersonCamera.transform.forward * 10f;
    4.         Vector3 Diff = ThirdPersonCamera.transform.position - transform.position;
    5.  
    6.         float angle = Vector3.Angle(Diff, transform.forward);
    7.  
    8.         if (angle > 70)
    9.         {
    10.             lookAt.solver.IKPosition = FacingDirection;
    11.         }
    12.     }
    It's working fine when the character is standing still and just using the mouse to pan the camera around, however when turning the character (A and D keys rotate the character) it breaks, what I'm trying to do is it should not try to face backwards when the camera is pointing at somewhere behind the character
     
  15. sickbattery

    sickbattery

    Joined:
    Jul 13, 2014
    Posts:
    20
    I've got a problem with the script execution order :/ ... I need LookAt to come before Aim, but the order always resets. I have two weapons with two AimIK scripts and I need them to execute after LookAt.
     
  16. CloudyVR

    CloudyVR

    Joined:
    Mar 26, 2017
    Posts:
    715
    As stated by the author it is not necessary to use IKExecution order:

    However if you do decide to use IKExecutionorder then what I have found is populating that list can be a little tricky, try right clicking of the elements in the list if you have to remove any of them, also when adding multiple IK components to the list from the same gameobject, the topmost IK component script will be added, then you have to re-order the components so the next IK component is on top, then you can drag it in and add it to the list.
     
    Partel-Lang likes this.
  17. sickbattery

    sickbattery

    Joined:
    Jul 13, 2014
    Posts:
    20
    Yes, a few minutes ago I found out about the IKExecutionOrder script ...

    Yeah, I LOLed when I saw this :). I duplicated and modified the script.

    Code (CSharp):
    1.     private IK[] _ikComponents;
    2.     private Animator _animator;
    3.  
    4.     // (...)
    5.  
    6.     // Disable the IK components
    7.     void Start()
    8.     {
    9.         _animator = GetComponent<Animator>();
    10.        
    11.         // my order
    12.         List<IK> ikComponentsList = new List<IK>();
    13.         ikComponentsList.Add(GetComponent<LookAtIK>());
    14.         ikComponentsList.AddRange(GetComponents<AimIK>());
    15.  
    16.         _ikComponents = ikComponentsList.ToArray();
    17.  
    18.         for (int i = 0; i < _ikComponents.Length; i++) _ikComponents[i].enabled = false;
    19.     }
    Thanks :).
     
  18. sickbattery

    sickbattery

    Joined:
    Jul 13, 2014
    Posts:
    20
    Ok. How do I exclude bones? I have a Dynamic Bone script for a chain that is attached to the right wrist, now the right arm also aims and I've got the feeling there is something wrong, because the chain is a bit off and the arm doesn't bend. Bones shoulder, upper arm, lower arm and hand are configured in the AimIK script ...
     
  19. Semashi

    Semashi

    Joined:
    Dec 8, 2015
    Posts:
    4
    Hi,

    Currently, I'm trying to introduce VRIK into my character with Vive, but it doesn't work fine.
    upload_2018-3-25_0-38-56.png

    As you can see, right knee angle is inverted. It happens on both legs and often flips between inverted and non-inverted.
    When I tried with Unity-chan, it works fine (no invert happened). I modified various Right/Left leg and Locomotion params on VRIK script, but cannot be fixed. How to fix this?
     
  20. Semashi

    Semashi

    Joined:
    Dec 8, 2015
    Posts:
    4
    It solved by doing like below.

    1. Remove animator controller to disable any other animations
    2. Knee default angle is set slightly bended to proper direction
     
  21. sickbattery

    sickbattery

    Joined:
    Jul 13, 2014
    Posts:
    20
    Ok. I fixed it ... is there anything that can't be fixed with the Script Execution Order?
     
  22. Partel-Lang

    Partel-Lang

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

    With the IK components you are supposed to move the targets, not the gameobjects directly. For instance in the CCD demo, you should select the gameobject that has the IK component, then the blue target in the Scene View and move that, not the individual bones in the chain:
    CCD Target.PNG

    In Aim Boxer, you can't move the toe directly because the character is animated and the Animator overwrites your changes every frame.

    Hey,
    Have you tried increasing the "Clamp Weight"? It makes the character face forward when the target is behind it.

    Hey,
    Glad you already found the answer. The leg bending code has been reworked for the next version and hopefully will put an end to this common bend angle problem.

    Yeah, just cancer.

    Cheers,
    Pärtel
     
  23. kerrmedia

    kerrmedia

    Joined:
    Nov 4, 2015
    Posts:
    250
    Newbe question, getting this error while trying to copy over Grounder demo.


    NullReferenceException: Object reference not set to an instance of an object
    RootMotion.Demos.CharacterAnimationSimple.Update () (at Assets/Plugins/RootMotion/Shared Demo Assets/Scripts/Character Controllers/CharacterAnimationSimple.cs:34)

    null_error.JPG
     
  24. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hey,
    The error occurs because there is no Animator on that GameObject or any of it's children. Where is that spider's Animator?
     
    kerrmedia likes this.
  25. VisionToRevision

    VisionToRevision

    Joined:
    Feb 8, 2017
    Posts:
    2
    Hi Partel,

    Does VRIK make any assumption about the default orientations of transforms in the rig?
    I've been looking all over the documentation and forum for an answer to this, and can't find anything about it. Your pilot rig follows the "X axis pointing along the bone chain leading back to the root, Y axis pointing forward of the mesh". When I try to use VRIK on one of our rigs that follows a different convention, I get crazy results (character all twisted up in a crab-like position floating in the air). Is the rigging the issue, or should I be looking somewhere else?

    Thanks!
     
  26. VisionToRevision

    VisionToRevision

    Joined:
    Feb 8, 2017
    Posts:
    2
    Another question while I'm at it: Does it matter where the VRIK script is located as long as it's pointing at the right transforms?
     
  27. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    397
    I'm having two issues with final IK / Puppetmaster / Grounder

    For some reason my knee is rotating very far out of place when my character is running and it looks bad :( I'm not sure what is causing this issue.


    My second issue is that I can't get the 2nd arm to hold onto my gun with my first hand. It matches near the default aim position but when the aim is moved to more extreme angles the 2nd hand doesn't follow the first. Below is the script I'm using for the 2nd arm.



    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using RootMotion.FinalIK;
    4. using Goon;
    5. using RootMotion;
    6.  
    7. public class SecondHandOnGun : MonoBehaviour
    8. {
    9.     public AimIK aim = null;
    10.     public FullBodyBipedIK ik;
    11.     public LookAtIK look;
    12.     [SerializeField]
    13.     private Transform lookTarget;
    14.     private Transform staticLookTarget;
    15.     public Recoil recoil;
    16.     private Quaternion rightHandRotation;
    17.     public Vector3 gunHoldOffset;
    18.     public Vector3 leftHandOffset;
    19.  
    20.     [SerializeField]
    21.     private Transform pistolTransform;
    22.  
    23.     private IKEffector leftHand { get { return ik.solver.leftHandEffector; } }
    24.     private IKEffector rightHand { get { return ik.solver.rightHandEffector; } }
    25.  
    26.     //private Quaternion leftHandRotationRelative;
    27.     private Vector3 leftHandPosRelToRightHand;
    28.     private Quaternion leftHandRotRelToRightHand;
    29.     private PlayerAim pAim;
    30.  
    31.     public BipedLimbOrientations customLimbOrientations;
    32.  
    33.     // Use this for initialization
    34.     void Start ()
    35.     {
    36.         aim.enabled = false;
    37.         look.enabled = false;
    38.         ik.solver.SetLimbOrientations(BipedLimbOrientations.MaxBiped);
    39.         pAim = ObjectReferences.playerController.GetComponent<PlayerAim>();
    40.         staticLookTarget = ObjectReferences.player.GetComponentInChildren<StaticLookTarget>().transform;
    41.     }
    42.  
    43.     void OnEnable()
    44.     {
    45.         look.solver.target = lookTarget;
    46.         look.enabled = false;
    47.         aim.enabled = true;
    48.  
    49.         if (aim != null && aim.solver != null)
    50.         {
    51.             aim.solver.transform = pistolTransform;
    52.         }
    53.  
    54.         if (ik != null) ik.solver.OnPreRead += OnPreRead;      
    55.     }
    56.  
    57.     void OnDisable()
    58.     {
    59.         look.solver.target = staticLookTarget;
    60.         look.enabled = true;
    61.         aim.enabled = false;      
    62.  
    63.         leftHand.positionWeight = 0f;
    64.         rightHand.positionWeight = 0f;
    65.         aim.solver.transform = null;
    66.         if (ik != null) ik.solver.OnPreRead -= OnPreRead;
    67.     }
    68.  
    69.     // Update is called once per frame
    70.     void LateUpdate ()
    71.     {
    72.         Read();
    73.  
    74.         aim.solver.IKPosition = look.solver.IKPosition;
    75.         aim.solver.Update();
    76.  
    77.         rightHandRotation = ik.references.rightHand.rotation;
    78.  
    79.         Vector3 rightHandOffset = ik.references.rightHand.rotation * gunHoldOffset;
    80.         ik.solver.rightHandEffector.positionOffset += rightHandOffset;
    81.  
    82.         if (!pAim.gun.isDrawing && !pAim.gunScript.reloading && !pAim.gunScript.overheating && !ObjectReferences.playerController.isRolling && !ObjectReferences.playerController.isJumping)
    83.         {
    84.             recoil.SetHandRotations(rightHandRotation * leftHandRotRelToRightHand, rightHandRotation);
    85.         }
    86.         else
    87.         {
    88.             recoil.SetHandRotations(leftHand.bone.rotation, rightHandRotation);
    89.         }
    90.  
    91.         ik.solver.Update();
    92.  
    93.         // Rotating the hand bones after IK has finished
    94.         if (recoil != null)
    95.         {
    96.             ik.references.rightHand.rotation = recoil.rotationOffset * rightHandRotation;
    97.             if (!pAim.gun.isDrawing && !pAim.gunScript.reloading && !pAim.gunScript.overheating && !ObjectReferences.playerController.isRolling && !ObjectReferences.playerController.isJumping)
    98.             {
    99.                 ik.references.leftHand.rotation = recoil.rotationOffset * rightHandRotation * leftHandRotRelToRightHand;
    100.             }
    101.         }
    102.         else
    103.         {
    104.             ik.references.rightHand.rotation = rightHandRotation;
    105.             if (!pAim.gun.isDrawing && !pAim.gunScript.reloading && !pAim.gunScript.overheating && !ObjectReferences.playerController.isRolling && !ObjectReferences.playerController.isJumping)
    106.             {
    107.                 ik.references.leftHand.rotation = rightHandRotation * leftHandRotRelToRightHand;
    108.             }
    109.         }
    110.  
    111.         // Rotate the head
    112.         look.solver.Update();
    113.     }
    114.  
    115.     private void Read()
    116.     {
    117.         // Remember the position and rotation of the left hand relative to the right hand
    118.         leftHandPosRelToRightHand = ik.references.rightHand.InverseTransformPoint(ik.references.leftHand.position);
    119.         leftHandRotRelToRightHand = Quaternion.Inverse(ik.references.rightHand.rotation) * ik.references.leftHand.rotation;
    120.     }
    121.  
    122.     // Final calculations before FBBIK solves. Recoil has already solved by, so we can use it's calculated offsets.
    123.     // Here we set the left hand position relative to the position and rotation of the right hand.
    124.     private void OnPreRead()
    125.     {
    126.         Quaternion r = recoil != null ? recoil.rotationOffset * rightHandRotation : rightHandRotation;
    127.      
    128.         if(!pAim.gun.isDrawing && !pAim.gunScript.reloading && !pAim.gunScript.overheating && !ObjectReferences.playerController.isRolling && !ObjectReferences.playerController.isJumping)
    129.         {
    130.             Vector3 leftHandTarget = ik.references.rightHand.position + ik.solver.rightHandEffector.positionOffset + r * leftHandPosRelToRightHand;
    131.             ik.solver.leftHandEffector.positionOffset += leftHandTarget - ik.references.leftHand.position - ik.solver.leftHandEffector.positionOffset + r * leftHandOffset;
    132.         }      
    133.     }
    134.  
    135.     // Cleaning up the delegates
    136.     void OnDestroy()
    137.     {
    138.         if (ik != null) ik.solver.OnPreRead -= OnPreRead;
    139.     }
    140. }
    141.  
     
  28. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hey,
    The only things that matter regarding bone orientations, is that VRIK like all IK components in FIK needs the targets to be oriented the same way as the bones. So for example the arm will be solved so that the hand bone rotation will match exactly with the hand target rotation.

    If you are replacing the character in a VRIK rig and that new character has different bone orientations, you'll also need to adjust the localRotations of the head and hand targets to match that new orientation.

    1 more thing.. The "Wrist To Palm Axis" and "Palm To Thumb Axis" under the arms settings of VRIK depend on the hand bone orientations. You can just right-click on the VRIK's header and select "Guess Hand Orientations" from the context menu after you have replaced the character.

    That's all you need to care about VRIK and bone orientations.

    It does not matter, but I usually keep it on the root of the character, where the Animator is.

    Hey,
    About the first problem, I see you are already calling ik.solver.SetLimbOrientations which usually fixes this, so it might be an animation retargeting issue. Does it help if you enable "Foot IK" for that running animation state in the Animator? It's best to keep that enabled for all locomotion animation if you are using Humanoid animations that were not created for that character model.

    About the second problem, I see you are enabling AimIK in OnEnable and also calling aim.solver.Update so AimIK is probably updating twice each frame, which might be the problem here.

    Best,
    Pärtel
     
  29. aaornrylow

    aaornrylow

    Joined:
    Jul 28, 2013
    Posts:
    4
    Hi Pärtel,

    I'm trying to set up a simple motion capture system using Oculus Rift + Touch, VRIK, and the experimental Unity class called GameObjectRecorder. Because VRIK is already pretty great at approximating full-body motion, ideally, I'd like to just record the whole thing as a humanoid animation, and then tweak bend goals and use bone masks for fine-tuning. Unfortunately, the class can only record generic animations so far, and I have no idea how to convert a generic animation to a humanoid within Unity.

    So I tried a workaround of just recording the hand and head transforms, using your VRIK Oculus implementation and a simple mirror to pose in. I created a parent object called GameObjectRecorder with Unity's example script from the documentation, and zeroed it out. I then created empty GameObjects on the pilot's RightArmHand, LeftArmHand, and and NeckHead, zeroed them out and moved them to the GameObjectRecorder. I put a simple script on each of those empty gameobjects to make them follow the pilot's corresponding transforms in Update(). Success so far: GameObjectRecorder recorded the animations for the 3 transforms.

    Then I tried (in a new scene), using the GameObjectRecorder's newly created animation, to use its children as effectors for FBBIK. It works pretty great for the hands! As long as the scale is correct, the hands and arms play out pretty much the same animation as I recorded. What I can't figure out is the head. I tried playing around with HeadEffector, and LookAtIK, but I couldn't seem to get the head animation working.

    Am I going about this all wrong? Is there a better way to reverse engineer VRIK's solution than using FBBIK? Am I recording the correct transforms to use as effectors?

    Any insight you could provide would be greatly appreciated.

    Thanks,
    -Aaron

    P.s. I'm loving FinalIK. Thanks for all your hard work and dedication to support.

    Edit:
    I changed my GameObjectRecorder children to follow the head (under spine), left arm, and right arm effectors, and then played them back on another character with VRIK using the animated effectors. Seems to look exactly as recorded. A pretty spectacular result for a guy with zero animation experience! I'll need to play around with the elbows and legs a bit to perfect it, but all in all I'd say it is a rousing success.

    I should've spent more time playing around with VRIK before asking. I figured it wasn't as easily customizable as your other components, because there's no documentation on it as of yet. Any word on when we can expect some formal documentation for VRIK? Also, where can I find information on how to properly use the bend goals for the elbows?

    Thanks again!
     
    Last edited: Mar 29, 2018
  30. pnuzhdin

    pnuzhdin

    Joined:
    Mar 26, 2018
    Posts:
    3
    Hi Pärtel,

    I have an issue with syncing positions of an arm and a gun. The arm and the gun are tracked by Vive Trackers independently.
    So when a user picks up the tracked gun by the tracked arm wrist it should be in a wrist instead of flying around as on the screenshot below. I've tried to transform the arm target object to be close as possible to the gun but it seems the VRIK solver rotates and moves the arm wrist a little bit so I always see such weird result. Have you any tips?

    Screen Shot 2018-03-29 at 00.13.52.png
     
  31. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    397
    I've enabled Foot IK for the animations but the problem persists. I'm using animations made for this character model but the model isn't fully compatible with the humanoid so I get warnings on the import about the head and neck. So I check the Generate Retargeting Quality Report and it gives me
    LeftFoot average position error 0.4 mm and maximum position error 2.1 mm at time 0:13 (72.2%) Frame 13
    LeftFoot average position error 0.3 mm and maximum position error 2.3 mm at time 0:4 (22.2%) Frame 14
    Not sure if that may be responsible for the issue or not.

    Also for the 2nd issue when I set the aim.enabled to false only the gun is forced on target and the left and right arm don't move up and down with the aim like they do if I have the AimIK script enabled so it seems like I'm missing a step somewhere in the update. I've basically just copied the AnimatorControllerThirdPersonIK script.
     
  32. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hey,
    About recording the IK, I am actually working on a baking tool that would enable you to bake the IK directly to Humanoid/Generic/Legacy animation clips. If you'd be interesting in beta testing that, please write to me support@root-motion.com or PM.

    I'm still working on a couple of additional features for VRIK and once that's done, I'll make some formal documentation pages. Anyway, for now all the info that will go to that documentation is already in the tooltips of the VRIK component.

    About the bend goals, just assign a gameobject as the "Bend Goal", set "Bend Goal Weight" to 1 and the arm will be bent towards that gameobject.

    Hey,
    Please pause the game, then check if hand bone positions/rotations match with the IK targets. If they do, that means the IK is working just fine and you'll have to adjust the pivots of the IK targets. Are you sure the pivot of the gun matches exactly the tracker position on the gun controller? Even if you manage to get the pivots exactly right, I bet there will be some minor but still annoying drifting of the gun due to tracking error, so you might want to parent the gun to the hand when it's picked up.

    Hey,
    One more thing to try. Could you go to the avatar configuration scene and decrease the max value of "Lower Leg Stretch" for both legs under Muscles & Settings?

    If that doesn't help either, could you send me that character fbx and that animation fbx so I could take a look myself?
    If you can send a repro project, I could also help you with that other problem, very difficult to guess what might be set up wrong there without being able to see it.

    Cheers,
    Pärtel
     
  33. w_adams

    w_adams

    Joined:
    Apr 7, 2016
    Posts:
    34
    Hi, I just bought Final IK and I'm wondering if there's a built-in or best practice to manipulate the end of a CCD chain using a physics-based VR interaction system (steamVR)?I 've accomplished it in a pretty hacky way updating the position of the target gameobject (Which I can't seem to manipulate with rigidbody interactions) with another gameobject that I can set up to interact with, but I'm assuming there's a better way to do this. Any pointers are appreciated, thank you.
    Also, I'm attempting to use this to rig surgical booms. Would you use CCD for that? (lots of rotational limits)
     
    Last edited: Mar 30, 2018
  34. kerrmedia

    kerrmedia

    Joined:
    Nov 4, 2015
    Posts:
    250
    Well, not sure. I have these working using Nav mesh fine in another project. Wanted to add IK, so just brought a prefab into your demo scene and copied over the bot IK stuff. Here is an animator property on the spider. spider_animator.JPG
     
  35. KPE

    KPE

    Joined:
    Sep 10, 2017
    Posts:
    2
    Hi, I just bought Final IK, and are going through the demos. FirstPersonAim and FirstPersonRecoil has some glitches when you enable "Animate Physics" on the demo. It seems like the aim is lost in a frame or two, any now and then, which causes some screen flickering. It is also present when I build and run the scene.

    I believe that final IK should work with physics, so can there be any setting in the rendering setup or similar that causes this problem?
     
  36. S4UC1SS0N

    S4UC1SS0N

    Joined:
    May 29, 2014
    Posts:
    49
    Hello ! I hope i'm not asking something already answered, i read a few pages, some issues sounds similar but i didn't find out if i could translate the explanations to my problem.

    I'm using AimIK on the head of the player so it follows the camera direction, it works great.
    When the player shoot, i'm using the head as the initial position/rotation for the projectile, again it works.
    But i just added the option to set a delay before some projectile are launched, for this, i simply added "yield return new WaitForSeconds(preparationTime);" since i'm already using a coroutine to manage the shooting action.
    But here is my problem, when i do this, the moment i read the head position/rotation in the coroutine, it's not retargeted by the AimIK.

    I guess it has something to do with the execution order but i've no idea how to solve this in the context of a coroutine, i saw people talking about "IKExecutionOrder" on this very page but don't understand how to use it or if it's what i need.
     
  37. eobet

    eobet

    Joined:
    May 2, 2014
    Posts:
    176
    I bought both Final IK and Puppetmaster, and haven’t begun using them yet, but I’ve read through most of this thread now. I saw the mention that there’s no recovery from the stagger state, it’s really meant for falling, and I tried the FBBIK boxing example, and you can move the target so far so the avatar is unnaturally diagonal. So Puppetmaster adds falling, but there’s no support for having him instead take a step forward?

    So, if one would manually add a center of gravity check, the first thing a human biped would do would be to move the foot with the least weight on, to a target on the opposite side of the center of gravity. This should move the position of the player gameobject as well, so I wonder if it’s outside of the scope of this asset...

    To follow on the first question, there’s no self balancing support in this asset? It looks as if the VRIK setup can reposition the feet automatically, but this hasn’t been ported to the FBBIK solver?

    I’ve seen a few different IK implementations on YouTube where you can just move a target and the entire IK body walks right over to it, but that is not a feature of Final IK or Puppetmaster so far?

    EDIT: The Final IK + Puppetmaster Stagger Demo and a few others simply fall through the floor when you try them (Unity 2017.4.0f1).

    EDIT: Tried 2018.1.0b13 now as well, and many demos still fall through the floor, and for example, in the Puppet Extended demo, the balls you shoot at the puppet flies straight through without colliding with it.
     
    Last edited: Apr 3, 2018
  38. KPE

    KPE

    Joined:
    Sep 10, 2017
    Posts:
    2
    OK, figured the problem. Animator update mode was not set to "Animate Physics".
     
  39. Mikekan13

    Mikekan13

    Joined:
    May 30, 2015
    Posts:
    90
    Hey! I am trying to use props on my VR ragdoll. They seem to work well until I introduce a more complex object. I have a revolver that uses a joint for its cylinder so it can rotate and open for reloading. How would I go about getting the prop system to work for this?
     
  40. skinwalker

    skinwalker

    Joined:
    Apr 10, 2015
    Posts:
    509
    When I use Grounder FBBIK it pulls the character down so its feet touch ground, but the Y position stays the same. Is it possible to see what's the Y position when Grounder FBBIK is active so I can use it in my script as a starting point even if the grounder FBBIK is not active?
     
  41. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    397
    I figured out the first problem, it was an issue with the avatar settings. I had allow DoF translation setting checked. When I unchecked it the leg issue went away.
    Unfortunately it's very hard to make a repro project for my game. I investigated the 2nd problem more fully and found that when I draw the weapon out the first time the aiming works perfectly with the second hand now after adjusting some settings, however when I pull out the gun additional times the aiming chain gets stuck so to speak. I'm tweening the aim IKPositionWeight while drawing and holstering the gun. If I don't call aim.Update() until IKPostionWeight is 1 then there is no problem either, but when I call aim.Update() while increasing IKPositionWeight from 0 to 1 something along the line prevents the aim from fully getting into the position it would get to if I had only called update once IKPositionWeight got to 1. I'm having trouble figuring out what is blocking the aim.Update() from using the current IKPositionWeight instead of the value it first receives.
     
  42. PerunCreative

    PerunCreative

    Joined:
    Nov 2, 2015
    Posts:
    113
    Hi,

    I have issues with colliders when used with VRIK. The colliders on childs of GameObject with VRIK are not alligned (they have the same position as without VRIK or as if IK Weight = 0).

    This is what it looks like:

    example0.PNG

    As you can see all the colliders are positioned incorrectly. When I was going through the forum I noticed issue related to mine and back then you said that in the VRIK Basic scene you tried adding collider + rigidbody on hand and it worked. So I tried it there and VRIK + Colliders really works in that demo scene without problem, so I started searching what is different and I found out that there is general problem in VRIK. The demo scene worked only because there are multiple VRIK instances, once you will remove one out of those 3 characters, colliders became immediately incorrect. Example (one sphere collider + rigidbody on the head bone of the pilot):

    example1.PNG
    example2.PNG

    After this I was searching more and discovered that there is always one character that doesn't work. It seems that it is always the last one added. So If you have 2 characters then first works ok and second is broken. Adding 3rd solves the second one, but doesn't work itself. However it doesn't always work that way, since I need only one character I tried to solved this problem by adding another character outside of the map, but even though the colliders on the main character were align properly (at least in the physics debug window) once I tried the collision with some other colliders they were still only colliding on places were colliders would be without VRIK and not on position where the characters and bones were actually displayed.
     
  43. manuelgoellnitz

    manuelgoellnitz

    Joined:
    Feb 15, 2017
    Posts:
    397
    Hi,
    sorry for the long delay.

    - We don't have any code that handles the controllers leave the tracked area.

    - We have a character height calibration system but this modifies the scale only once and the characters are fine then, the error occured far later. (So i ruled that out)

    - I programmed a workaround which checks the position every frame to NaN and sets it to 0, when the error occurs. This helps sometimes. But there seams to be a second variant of this error that continuesly sets the position to NaN. Then we get only one error message:

    Look rotation viewing vector is zero
    UnityEngine.Quaternion:INTERNAL_CALL_LookRotation(Vector3&, Vector3&, Quaternion&)
    UnityEngine.Quaternion:LookRotation(Vector3, Vector3)
    RootMotion.FinalIK.VirtualBone:GetDirectionToBendPoint(Vector3, Single, Vector3, Single, Single) (at C:\Users\ManuelG\wkspaces\dokaVDC\Unity Project\Assets\Plugins\RootMotion\FinalIK\IK Solvers\IKSolverVRUtilities.cs:171)
    RootMotion.FinalIK.VirtualBone:SolveTrigonometric(VirtualBone[], Int32, Int32, Int32, Vector3, Vector3, Single) (at C:\Users\ManuelG\wkspaces\dokaVDC\Unity Project\Assets\Plugins\RootMotion\FinalIK\IK Solvers\IKSolverVRUtilities.cs:151)
    RootMotion.FinalIK.Leg:Solve() (at C:\Users\ManuelG\wkspaces\dokaVDC\Unity Project\Assets\Plugins\RootMotion\FinalIK\IK Solvers\IKSolverVRLeg.cs:225)
    RootMotion.FinalIK.IKSolverVR:Solve() (at C:\Users\ManuelG\wkspaces\dokaVDC\Unity Project\Assets\Plugins\RootMotion\FinalIK\IK Solvers\IKSolverVR.cs:431)
    RootMotion.FinalIK.IKSolverVR:OnUpdate() (at C:\Users\ManuelG\wkspaces\dokaVDC\Unity Project\Assets\Plugins\RootMotion\FinalIK\IK Solvers\IKSolverVR.cs:291)
    RootMotion.FinalIK.IKSolver:Update() (at C:\Users\ManuelG\wkspaces\dokaVDC\Unity Project\Assets\Plugins\RootMotion\FinalIK\IK Solvers\IKSolver.cs:61)
    RootMotion.FinalIK.IK:UpdateSolver() (at C:\Users\ManuelG\wkspaces\dokaVDC\Unity Project\Assets\Plugins\RootMotion\FinalIK\IK Components\IK.cs:27)
    RootMotion.SolverManager:LateUpdate() (at C:\Users\ManuelG\wkspaces\dokaVDC\Unity Project\Assets\Plugins\RootMotion\Shared Scripts\SolverManager.cs:113)

    [C:\buildslave\unity\build\artifacts/generated/common/runtime/MathBindings.gen.cpp line 92]
    (Filename: C:/Users/ManuelG/wkspaces/dokaVDC/Unity Project/Assets/Plugins/RootMotion/FinalIK/IK Solvers/IKSolverVRUtilities.cs Line: 171)


    Some additional information which might be helpfull:
    - We use vrik.solver.AddPlatformMotion() for detecting teleportation, which is our main way of moving the character
    - The Player can change the charcter model. When he does that, VRIK gets reinitialized and the character reapears
    - It also happened when the HMD stayed in the tracked area
    - The position data comes not directly form the HMD but is relayed through Unity Photon Networking. We build a multiplayer application and VRIK runs on more then one client and on multliple player objects. The error occured simultaneusly on every one of them.
     
  44. warreneng

    warreneng

    Joined:
    Mar 13, 2017
    Posts:
    8
    Hi Pärtel,

    Is there any way to get the limb stretching feature that was added to VRIK in the 1.7 into the 1.6 release? I have everything I want working nicely with 1.6, but the jump to 1.7 adds other unexpected behavior to VRIK that I don't want. I tried copy/pasting the IKSolverVRArm class from 1.7 into my project over the existing 1.6 version but it didn't work.

    Please advise, thanks!
     
  45. CGDever

    CGDever

    Joined:
    Dec 17, 2014
    Posts:
    156
    Hi Pärtel,
    I need to lower the camera to the value of the character's shift down (Grounder).
    How can I get a displacement of the character's body?

    Thank you in advance)
     
  46. doEvents

    doEvents

    Joined:
    Aug 22, 2014
    Posts:
    1
    hello
    i use FinalIK and 3rdPersonShooter (Invector) same object
    if FullBodyBipedIK Active, animation look ugly when put or get weapon



     
  47. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hi guys, I apologize for the massive daly, I was on a short vacation this week.

    Hey, If you want physical interactions, I would probably be best to set the rig up with Rigidbodies, Joints and Colliders. You can use a very high drag value to keep the links stead and make everything kinematic while you are not interacting with it. You can use a kinematic rigidbody and a joint as the end effector that you manipulate.

    Hey,

    If you open CharacterAnimationSimple.cs, it uses
    Code (CSharp):
    1. animator = GetComponentInChildren<Animator>();
    in Start, so line 34 can through a null reference exception only if there is no Animator on the gameobject that has the CharacterAnimationSimple.cs component or on any of it's children.

    Hey,
    FIK components are normally updated in LateUpdate, after the animation. Coroutines in Unity are fired before that if you shoot a projectile from a coroutine, it will shoot form a pre-IK position of the bone. You can use that coroutine to raise a flag instead
    Code (CSharp):
    1. shootProjectile = true;
    , then use that flag to fire a projectile in LateUpdate from a script that has been set to a higher value than AimIK in the Script Execution Order.

    Hey,
    Falling through the floor probably happens not because of the Unity version, but because you have imported PM to a project that has a different Layer Collision Matrix than what the default Unity project has. Try importing to a new empty project.

    About taking steps towards to the target, that is best solved by simple locomotion animation. So if the target is too far from the root of the character, use a standard 8-direction strafing locomotion blend tree (such as the "Grounded Strafe" state in "Humanoid Third Person" animator controller) to move the character closer to the target.

    Hey,
    I'm sorry, were you referring to the InteractionSystem in FIK or the Prop system in PuppetMaster?
    How exactly does that barrel joint mess up the prop system?

    Hey,
    If Grounder's IK component is not active the grounder will not update.
    Normally you could get the y position offset applied by the Grounder by using the grounder.OnPostGrounder delegate
    and reading grounder.solver.pelvis.IKOffset from there, but that won't be called if FBBIK is disabled.

    Hey,
    I'd focus on why the IK works the first time and doesn't work the second time. Something must be changing with the process. Do you have "Fix Transforms" enabled in the IK component? If it's not, maybe you have some unanimated bones used bu IK that get rotated off and won't reset. If you could run 2 characters in an isolated scene. Draw the gun on one of them once, then check the bones and other objects in the hierarchy to see what is different on the two characters.

    Hey,
    Can't think of a reason why this would happen. Tried adding a collider to the Pilot's head and deleting other characters, but seemed to work fine. Which Unity version are you using?

    Hey,
    It's will probably be very difficult to solve based on descriptions, any chance you could send me the project so I could run it in the Editor?

    If you are teleporting, just move the character and call ik.solver.Reset() after that.

    Hey,
    Copy the IKSolverVRArm as you did, then you'll also need to copy the code from
    Code (CSharp):
    1. public override void FixTransforms()
    and
    Code (CSharp):
    1. private void WriteTransforms()
    from IKSolverVR.cs.
    May I ask what exactly was the unexpected behavior keeping you from updating to 1.7?

    Hey,
    By using the grounder.OnPostGrounder delegate and reading grounder.solver.pelvis.IKOffset from there.

    Hey,
    Did you mean the animation is looking bad just because the FBBIK component is enabled? Are you set any IK effector weights to 1 or is it just FBBIK enabled with no effectors weighed in?

    Could you select the character in the Scene View (while not playing) and see if the little blue arrows on the elbows point in the direction that the arm is supposed to bend towards?

    Best,
    Pärtel
     
  48. PerunCreative

    PerunCreative

    Joined:
    Nov 2, 2015
    Posts:
    113
    I am using unity 2017.2.2p3. What version you are on?
     
    Last edited: Apr 7, 2018
  49. Mikekan13

    Mikekan13

    Joined:
    May 30, 2015
    Posts:
    90
    I was referring to the PuppetMaster Prop system. The cylinder where I load bullets into is attached to the revolver with a joint. It seems to lag behind the revolver when the revolver is attached via the prop system.
     
  50. kokkorollo

    kokkorollo

    Joined:
    Jan 16, 2013
    Posts:
    9

    Hi Pärtel,
    I'm having the same problem as this user.

    Basically sometimes the character vanish, and there is NaN errors.
    when this happens unity tells that the VRIK character is too far away or in invalid position.
    There is a way to reset the character if something like this happens?

    don't seems that the problem is related to the controller or oculus position.
    now i will try to detect difference in distances on headset and controllers to detect lost tracking, so maybe this will solve the problem.

    But as I said, I want to Know if there is a way to reset the character to make him appear again, and make him behave like if is following head and controllers.
    Thanks!