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

    newfinalflashers

    Joined:
    Mar 1, 2014
    Posts:
    27
    Hello Partel,
    I am making a TPS and was using the interaction script for making the character Reload the Gun. Although the script works like it is supposed to; when using the interaction, the interact script moves the characters hand to the position the hand should be in if the grounderfbbik and aimik components of the character were disabled making the hand end up way too high in the air(from grounderfbbik) and with wrong rotation(aimik). I disabled/enabled them in play mode and saw that the hand went to the same position and did not take in the grounderfbbik and aimik offsets into consideration. what can I do to fix this error?
     
  2. newfinalflashers

    newfinalflashers

    Joined:
    Mar 1, 2014
    Posts:
    27
    I would also like to know if I can set up some sort of pole for the elbow that fluctuates in weight during the interaction
     
  3. Partel-Lang

    Partel-Lang

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

    Please import this patch, might be something that has already been fixed for the next version.

    About the pole for the elbow, you can add a Bend Goal for the arm. There's no weight curve for bend goal weight in the InteractionObject now, but you can still use it like this:

    Code (CSharp):
    1. public InteractionSystem intSys;
    2.     public AnimationCurve bendGoalWeightByInteractionProgress;
    3.  
    4.     void LateUpdate() {
    5.         intSys.ik.solver.leftArmChain.bendConstraint.weight = bendGoalWeightByInteractionProgress.Evaluate(intSys.GetProgress(FullBodyBipedEffector.LeftHand));
    6.     }
     
  4. abhishekg98

    abhishekg98

    Joined:
    May 13, 2017
    Posts:
    1
    @Partel-Lang I liked Final Ik very much. And I am using it in my project. I tried to experiment with VRIK and I am unable to find any documentation on VRIK by you. Please help and reply as soon as possible.
     
  5. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hey,
    The component is still evolving, for now all the documentation is in the variables of VRIK that are extensively tooltipped.

    Best,
    Pärtel
     
  6. wirelessdreamer

    wirelessdreamer

    Joined:
    Apr 13, 2016
    Posts:
    134
    With the new module, I'm still having issue with the hands, both hands are offset by 90 degrees now. I'm using morph3d characters in this one.

    upload_2017-12-19_10-14-23.png
     
  7. newfinalflashers

    newfinalflashers

    Joined:
    Mar 1, 2014
    Posts:
    27
    Thank you very much for your quick response, and your solutions did fix my issue. However, I've been experiencing a new error over the past few days with the interaction system offsets. I've already made the curve and after adding in a few logs on the console it successfully shows that the position offsets are being called in the correct magnitudes but it is definitely not actually happening in the scene or game view. I read earlier posts that position offset was overridden by position weights (early HitReaction release) but even after editing it to only do offsets and not overall position weights the offsets were not applied to my characters hand. I have a swappable and very dynamic weapon system for my game so it is much more complicated and time consuming for me to animate the guns individually. Because of this, I use the interaction system for animating weapons and it has saved me a lot of time and it has worked except for scenarios that require offsets like reloading. I watched all the tutorials especially the first interaction one where you applied the hand offset to not go through the ball and could still not find out what was wrong with my project. Do you know what I can do to fix this problem? And once again thank you for your wonderful asset as it has saved me a lot of time.
     
  8. warreneng

    warreneng

    Joined:
    Mar 13, 2017
    Posts:
    8
    Hello @Partel-Lang,

    I have a tricky setup that I'm trying to get VRIK to play nicely with:

    In my VR game I'm using Mechanim to animate the character in 3 layers: a "body" layer that uses an AvatarMask to apply running animations only to the root + feet + legs + chest. I have a "left hand" and "right hand" layer that uses an AvatarMask to apply finger animations to the hands.

    I use VRIK to pose the character when stationary (or the user is walking in within their physical space). At this time I set the body layer's weight in the Animator to 0 so VRIK gets control of everything except the fingers.

    The problem is that VRIK poses the character's legs through the floor up to his pelvis. When I disable the Animator component, VRIK solves the legs to the floor properly.

    I have a feeling that the animation clips might be screwing with the Avatar bones, but I'm not sure.

    Any help will be greatly appreciated!

     
  9. DrInternet

    DrInternet

    Joined:
    Apr 6, 2014
    Posts:
    106
    Hello,
    1. how do I apply rotation limits to VRIK? Rotation limit angle component doesn't seem to work.
    2. How can I turn off the walking function? I want my character to move alongside HMD, crouch and rotate, but I want to get rid of this creepy walk.
    3. How can I 'dull' the bones movement? The problem is, twisting my wrist irl causes in-game elbow to move quite a long distance.
     
  10. tareksalah

    tareksalah

    Joined:
    Jan 28, 2017
    Posts:
    16
    >>

     
    Last edited: Dec 21, 2017
  11. BernieRoehl

    BernieRoehl

    Joined:
    Jun 24, 2010
    Posts:
    81
    So, I'm struggling a bit with networking using VRIK. It's mostly working, but I have an odd problem that I'm sure there's an easy solution for.

    I'm using Photon. I have a prefab that I instantiate over the network which has an empty GameObject called NP and empty GameObjects under NP for the head and both hands. When that prefab is instantiated, it sets up a character as a child of NP and adds a VRIK component to the character, with the VRIK head and hand fields pointing to the head and hand child objects of NP. In other words, it looks like this:

    Code (csharp):
    1. NP
    2.     head
    3.     left hand
    4.     right hand
    5.     avatar with VRIK component that points to the head, left hand and right hand
    6.         avatar geometry...
    7.         mixamo skeleton, referenced by VRIK
    In Update(), I read the (world-space) position and orientation of the SteamVR [CameraRig] and apply them to NP. I also read the localPosition and localOrientation of the head and hands under the [CameraRig] and copy them into the head and hands under NP. All of this works fine, and my avatar moves perfectly when I move my real-world head and hands.

    When I serialize the data over the network, I send the world-space position and orientation of NP and the local position and orientation of the head and hands. When I deserialize on the other end, I interpolate from the current position and orientation of each of those to the newly-received values, using worldspace for NP and local space for the head and hands.

    All of this works fine. I move at one end, the avatar moves at the other ends, looks great. I can walk around, wave -- everything.

    When the player wants to move beyond the limits of their playspace, I move the [CameraRig]. This also works fine, and my avatar (both locally and on the other end) move smoothly through space. I even have a walking animation that looks reasonable (I set vrik.solver.locomotion.weight = 0 while walking and set it back to 1 when the walking is done). This also works.

    If the user want to move farther away by teleporting, that works too -- on the receiving end, I check if their position has changed by more than some small amount, and if so I reset the IK.

    So far so good.

    I want the user to be able to turn-in-place in steps of 45 degrees by using their controller. To do this, I rotate the playspace around the user's current position (not around the center of the playspace). That works fine locally, and it looks okay at the remote end when the user is standing in the middle of their playspace.

    However, when they've walked away from the center (in the real world) and then try to step-rotate, something odd happens at the remote end. The character leans over and jumps to the side, then jumps back again. It ends up correctly rotated, so the proper position/orientation have been applied. It's just the jump that I don't understand.

    Any suggestions? Feel free to tell me my entire approach is wrong. :)
     
    Last edited: Dec 21, 2017
  12. BernieRoehl

    BernieRoehl

    Joined:
    Jun 24, 2010
    Posts:
    81
    In case it wasn't clear from my description, here's the code that runs on NP:
    Code (csharp):
    1.  
    2. void Update()
    3. {
    4.     if (IsLocal())
    5.     {
    6.         // read the trackers and update the head and hand positions that VRIK uses
    7.         transform.position = playAreaTracker.position;
    8.         transform.rotation = playAreaTracker.rotation;
    9.         head.localPosition = headTracker.localPosition;
    10.         head.localRotation = headTracker.localRotation;
    11.         leftHand.localPosition = leftHandTracker.localPosition;
    12.         leftHand.localRotation = leftHandTracker.localRotation;
    13.         rightHand.localPosition = rightHandTracker.localPosition;
    14.         rightHand.localRotation = rightHandTracker.localRotation;
    15.     }
    16.     else
    17.     {   // remote end
    18.         if (Vector3.Distance(transform.position - playAreaTargetPosition) > teleportThreshold)
    19.         {   // user teleported, so just move them there and reset the IK solver
    20.             transform.position = playAreaTargetPosition;
    21.             transform.rotation = playAreaTargetRotation;
    22.             vrik.solver.Reset();
    23.         }
    24.         else
    25.         {   // regular movement, interpolate everything
    26.             transform.position = Vector3.MoveTowards(transform.position, playAreaTargetPosition, Time.deltaTime * interpolateSpeed);
    27.             transform.rotation = Quaternion.RotateTowards(transform.rotation, playAreaTargetRotation, Time.deltaTime * interpolateSpeed);
    28.             head.localPosition = Vector3.MoveTowards(head.localPosition, headTargetPosition, Time.deltaTime * interpolateSpeed);
    29.             head.localRotation = Quaternion.RotateTowards(head.localRotation, headTargetRotation, Time.deltaTime * interpolateSpeed);
    30.             leftHand.localPosition = Vector3.MoveTowards(leftHand.localPosition, leftHandTargetPosition, Time.deltaTime * interpolateSpeed);
    31.             leftHand.localRotation = Quaternion.RotateTowards(leftHand.localRotation, leftHandTargetRotation, Time.deltaTime * interpolateSpeed);
    32.             rightHand.localPosition = Vector3.MoveTowards(rightHand.localPosition, rightHandTargetPosition, Time.deltaTime * interpolateSpeed);
    33.             rightHand.localRotation = Quaternion.RotateTowards(rightHand.localRotation, rightHandTargetRotation, Time.deltaTime * interpolateSpeed);
    34.         }
    35.     }
    36. }
    37.  
    38. public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    39. {
    40.     if (stream.isWriting)
    41.     {
    42.         stream.SendNext(transform.position);
    43.         stream.SendNext(transform.rotation);
    44.         stream.SendNext(head.localPosition);
    45.         stream.SendNext(head.localRotation);
    46.         stream.SendNext(leftHand.localPosition);
    47.         stream.SendNext(leftHand.localRotation);
    48.         stream.SendNext(rightHand.localPosition);
    49.         stream.SendNext(rightHand.localRotation);
    50.     }
    51.     else
    52.     {
    53.         playAreaTargetPosition = (Vector3)stream.ReceiveNext();
    54.         playAreaTargetRotation = (Quaternion)stream.ReceiveNext();
    55.         headTargetPosition = (Vector3)stream.ReceiveNext();
    56.         headTargetRotation = (Quaternion)stream.ReceiveNext();
    57.         leftHandTargetPosition = (Vector3)stream.ReceiveNext();
    58.         leftHandTargetRotation = (Quaternion)stream.ReceiveNext();
    59.         rightHandTargetPosition = (Vector3)stream.ReceiveNext();
    60.         rightHandTargetRotation = (Quaternion)stream.ReceiveNext();
    61.     }
    62. }
     
    Last edited: Dec 21, 2017
  13. DigitalAdam

    DigitalAdam

    Joined:
    Jul 18, 2007
    Posts:
    1,209
    @Partel-Lang,

    I'm having some trouble getting my Mixed Reality Motion Controllers working with VRIK. The 'MotionControllerVisualizer.cs' script that comes with the Mixed Reality Toolkit allows me to use a Prefab in my Project directory, but not a Prefab in my scene.

    I tried to use the same prefab in my Project folder; adding that to the 'MotionControllerVisualizer' and your "VRIK' script. But when I Play the scene the MotionControllerVisualizer script creates a clone of the prefab, thus it's not being added to your script. I'm able to drag that cloned prefab into the Inspector slot of VRIK to get it to work after the Scene plays, but not before. Any suggestions?

    Thanks.
     
  14. newfinalflashers

    newfinalflashers

    Joined:
    Mar 1, 2014
    Posts:
    27
    @Partel-Lang
    Another problem I'm having with the interaction system is the reset default speed. Although I set it to zero, it still returns to the default animated position of the character every time the interaction switches/ends. Is there away I can make it so that as soon as an interaction finishes, the effectors remain in the same position and weight they were before or is there something wrong with my reset default speed. Thanks.
     
    Last edited: Dec 22, 2017
  15. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hey,
    Did you copy the VRIK component over from another character? If you did, right-click on VRIK header and select "Guess Hand Orientations".

    Hey,
    Any specific steps I could take to reproduce that issue? I mean the offsets seem to still work fine in all of the demos.

    Hey,
    Please try disabling VRIK when that happens. You are probably trying to play a generic animation clip on a humanoid character or vice versa, which would result in a sunken default pose like the one you see in the avatar configuration scene.

    Hey,
    Looks like you are sending the localPositions of the head and hand targets and applying them to localPosition on the receiving end, but you are not syncing the parent. So if the parent of the head and hands turns, the remote player will not receive that motion.

    Hey,
    Not sure if I understood you right, not really familiar with MotionControllerVisualizer. But couldn't you drag that model prefab to the scene, add VRIK to it, save it as another prefab and use that as the prefab that MotionControllerVisualizer instantiates instead?

    So if I understood you right, you need to keep the hand effector weight at 1 even after the interaction ends?
    You'll probably want to let go sooner or later, so unless your character needs to stay locked to that hand position until the end of the game, just add a Pause event to that interaction at a time when position weight is 1. Then you'll be able to get out of that situation eventually by calling InteractionSystem.Resume...

    Cheers,
    Pärtel
     
  16. BernieRoehl

    BernieRoehl

    Joined:
    Jun 24, 2010
    Posts:
    81
    I'm definitely syncing the parent's position and rotation. If I weren't, then walking and teleporting wouldn't work.
     
  17. BernieRoehl

    BernieRoehl

    Joined:
    Jun 24, 2010
    Posts:
    81
    Actually, I solved it. Since step-rotating the playspace is essentially moving the character (even though the character stays in-place), I have to reset the IK solver after doing a step-rotation.
     
  18. DrInternet

    DrInternet

    Joined:
    Apr 6, 2014
    Posts:
    106
    I love how you have answered all questions but mine. You surly know how to make customer feel special.

    EDIT: no, it looks like I wasn't the only one. Seems like this is a common behavior here.
     
    Last edited: Dec 22, 2017
  19. tareksalah

    tareksalah

    Joined:
    Jan 28, 2017
    Posts:
    16
    Hi @Partel-Lang ... Please note my question about the hips of the avatar not moving with the body ... I've posted my question on Wednesday 9:07pm.
    Appreciate your feedback
     
  20. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Oh, I'm sorry, happens sometimes trying to answer a ton of questions in a row, my apologies!

    1. Rotation Limits do not work with VRIK. It's just the nature of the algorithm that can't support that kind of stuff. You can still apply them after VRIK has solved though. You'll need to disable them at Start and call rotationLimit.Apply() from LateUpdate in a script that is either set to a higher value than VRIK in the Script Execution Order or from ik.solver.OnPostUpdate delegate.

    2. Just set locomotion weight to 0 in the VRIK settings, they your legs will be free to be animated via Mecanim.

    3. You can use the Bend Goals. Assign a Bend Goal to the arm in VRIK and set Bend Goal Weight to greater than 0.

    I'm sorry for missing your question too!

    Does increasing "Body Rot Stiffness" and "Neck Stiffness" help with this?

    Best,
    Pärtel
     
  21. mburrows

    mburrows

    Joined:
    Jun 18, 2017
    Posts:
    5
    Hello Partel!
    I want to use FBBIK for procedural animations, and want to use the "Toes-Bone" in my charakters model to animate some toe Tipping and more realistic looking walking and running animations with properly rolling feet.
    I simply tried to add the "Toe Bone" instead of the "Ankle Bone" in the FBBIK Foot-references, and it worked in a way, because it linked the end-effectors to the toetip, instead of the ankle. But the ankle joint remained fixed, and was just ignored by the solver. But i want it to be used as well, whenever the ankle joint bends to much - this would look very natural.
    I guess it would be possible to create a custom FABRIK Rig to do the job, but i would like to use the FBBIK, and maybe modify it in a way, that it supports my intentions.
    Do you understand, what i am up to, and if yes, what would be the best way to accomplish this, in your opinion ?

    Thank you in advantage!
     
  22. Mikekan13

    Mikekan13

    Joined:
    May 30, 2015
    Posts:
    90
    Ok I have spent countless hours trying to figure out this grounding stuff for VRIK. Is it impossible to have any kind of vertically? Like I can get the grounder to work pretty well when the game starts but if the player goes up or down at all then it no longer works.
     
  23. Kagyu

    Kagyu

    Joined:
    Mar 5, 2016
    Posts:
    96
    Hi Partel,

    GrounderFBBIK does not start working until the attached object picked in the hierarchy as it is shown in the video below.


    The fbx is loaded from an asset bundle, attached FBBIK then attached grounderFBBIKE by script.
    I attached it by following code.
    Code (CSharp):
    1.         GrounderFBBIK grounderFBBIK = actor[actor.Count - 1].AddComponent<GrounderFBBIK>();
    2.         grounderFBBIK.solver.layers = LayerMask.NameToLayer("Everything");
    Do you have any idea how I can activate FBBIKGrounder without clicking it in the hierarchy? At this moment, I have no way to make it working in a built exe.
    [Edit] By adding
    Code (CSharp):
    1. UnityEditor.Selection.setObjectActiveByContext
    the grounderFBBIK is activated right after it is attached, but as you know the function is in the unityEditor namespace then I cannot use it for ultimate solution...

    Thanks!
     
    Last edited: Dec 24, 2017
  24. AverInvestments

    AverInvestments

    Joined:
    Dec 9, 2017
    Posts:
    1
    Hi Partel,

    Thank you for this fantastic product. In your VRIK script you allow targets for head, left and right arms (hands) and left and right legs (feet). Could you please make a more generalised version of this script so that I can pick and choose which bones I want to set targets for? For example, rather than setting targets for the feet, I would rather have targets for the left and right calf. Perhaps make it so that I can change the number of bones that I want to set targets for?

    Thank you Partel!
     
  25. Bitboys

    Bitboys

    Joined:
    Apr 22, 2015
    Posts:
    156
    Hi. I don´t know if someone else has happened, but I'm going crazy to be able to synchronize the rotation of my character's arms online.
    I´m using Photon and for the arms rotation i´m using the Aim Ik component and the Rotation Limit Hinge. In local mode everything works fine, the arms follow the target with the camera movement but in network mode nothing happens.
    I have already tried everything, writing my own script to synchronize the weights, I also tried to synchronize the rotation of the joints, i tried using the photontransformview component,
    even blocking the character's animations does not work. It is something that is really taking time away from me and I do not know if it is really possible to synchronize the values of the ik.
    I'm desperate with this.:oops:
     
  26. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hey,
    FBBIK does not have support for using the toe bones. Adding that to FBBIK would make the solver quite a bit slower for 99% of the users who don't need it.

    But you could try the LegIK component, it is basically the leg solver from VRIK and has toe support.

    Hey,

    I guess you have already found the "VRIK (Grounder)" demo scene and using that approach? What exactly did you mean by it no longer working when the player goes up or down? Maybe it's that you are not keeping the root of the character at ground level and so if root.y is higher or lower than max step from the surface, the grounder stops working.

    Hey,
    If FBBIK is added in runtime, it doesn't automatically fill in the references for it, because it is done by an editor script that does it when the component is added in the editor (or when you click on the gameobject). You'll need a couple of more lines to initiate FBBIK that has been added in runtime. From the user manual:
    Code (CSharp):
    1. // Call this method whenever you need in runtime.
    2. // Please note that FBBIK will sample the pose of the character at initiation so at the time of calling this method,
    3. // the limbs of the character should be bent in their natural directions.
    4. void AddFBBIK (GameObject go, BipedReferences references = null) {
    5.     if (references == null) { // Auto-detect the biped definition if we don't have it yet
    6.         BipedReferences.AutoDetectReferences(ref references, go.transform, BipedReferences.AutoDetectParams.Default);
    7.     }
    8.     ik = go.AddComponent<FullBodyBipedIK>(); // Adding the component
    9.     // Set the FBBIK to the references. You can leave the second parameter (root node) to null if you trust FBBIK to automatically set it to one of the bones in the spine.
    10.     ik.SetReferences(references, null);
    11.     // Using pre-defined limb orientations to safeguard from possible pose sampling problems (since 0.22)
    12.     ik.solver.SetLimbOrientations(BipedLimbOrientations.UMA); // The limb orientations definition for UMA skeletons
    13.     // or...
    14.     ik.solver.SetLimbOrientations(BipedLimbOrientations.MaxBiped); // The limb orientations definition for 3ds Max Biped skeletons
    15.     // or..
    16.     ik.solver.SetLimbOrientations(yourCustomBipedLimbOrientations); // Your custom limb orientations definition
    17.     // To know how to fill in the custom limb orientations definition, you should imagine your character standing in I-pose (not T-pose) with legs together and hands on the sides...
    18.     // The Upper Bone Forward Axis is the local axis of the thigh/upper arm bone that is facing towards character forward.
    19.     // Lower Bone Forward Axis is the local axis of the calf/forearm bone that is facing towards character forward.
    20.     // Last Bone Left Axis is the local axis of the foot/hand that is facing towards character left.
    21. }
    Hey,
    VRIK is a solver built for a very specific purpose and for the maximum speed possible to get IK done for VR. I'm afraid switching out for a more generalised IK algorithm that would support more targets would also make it unbarable performance-wise for the already computation heavy VR games.
    Why do you need targets for the calves anyway? I could probably give you a suggestion for a workaround.

    Hey,
    Make sure the AimIK component is running on the remote instance and it is weighed in. Run the local one in a build and the remote one in the Editor, see if there are any errors/warnings coming from AimIK in the Console.
    If it's doing nothing, add a Debug.Log to IKSolverAim.cs at line 100 and let me know if that log is being called.

    Cheers,
    Pärtel
     
  27. Kagyu

    Kagyu

    Joined:
    Mar 5, 2016
    Posts:
    96
    Pärtel、

    I think adding FBBIK, setting references and limb orientation are completed in my coroutine.
    Head Effector and LookatIK is working right after I hit play. Only grounderFBBIK does not start working until I select the game object in the hierarchy. Do I miss anything? My model has humanoid rig so I put "ik.solver.SetLimbOrientations(BipedLimbOrientations.MaxBiped); " in my script.
    Here is what I have.
    Do you see any lacking?

    [ Edit ]
    Ah, got it!
    Code (CSharp):
    1.         grounderFBBIK.ik = ik;
    This is the thing! Now it is working without issue!
    Thank you so much for your help, always!


    Code (CSharp):
    1. using System.Collections.Generic;
    2. using UnityEngine;
    3. using RootMotion;
    4. using RootMotion.FinalIK;
    5.  
    6.  
    7. public static class SetUpActor
    8. {
    9.     private static Transform joint_Head;
    10.     private static Transform[] joint_Torso = new Transform[2];
    11.     private static Transform[] joint_Eyes = new Transform[2];
    12.     private static Transform root;
    13.     private static LookAtIK lookAtIK;
    14.  
    15.     private static AnimatorOverrideController overrideController;
    16.     private static Animator anim;
    17.  
    18.  
    19.  
    20.     //ActorにFBBIK, LookAtIK, HeadEffectorを設定
    21.     public static void ApplyFBBIK(GameObject obj)
    22.     {
    23.  
    24.         //Get all children's transform in obj
    25.         List<GameObject> bonesList = GetAllChildren.GetAll(obj);
    26.  
    27.         //Get needed transforms for LookAtIK
    28.         for (int i = 0; i < bonesList.Count; i++)
    29.         {
    30.             string name = bonesList[i].name;
    31.             if (bonesList[i].name.Contains("Col") == false)
    32.             {
    33.  
    34.                 if (bonesList[i].name.Contains(".joint_Head"))
    35.                 {
    36.                     joint_Head = bonesList[i].transform;
    37.                 }
    38.  
    39.                 if (bonesList[i].name.Contains(".joint_Torso"))
    40.                 {
    41.                     if (bonesList[i].name.Contains(".joint_Torso2"))
    42.                     {
    43.                         joint_Torso[1] = (bonesList[i].transform);
    44.                     }
    45.                     else
    46.                     {
    47.                         joint_Torso[0] = (bonesList[i].transform);
    48.                     }
    49.                 }
    50.  
    51.                 if (bonesList[i].name.Contains(".joint_LeftEye"))
    52.                 {
    53.                     joint_Eyes[0] = (bonesList[i].transform);
    54.                 }
    55.  
    56.                 if (bonesList[i].name.Contains(".joint_RightEye"))
    57.                 {
    58.                     joint_Eyes[1] = (bonesList[i].transform);
    59.                 }
    60.  
    61.                 if (bonesList[i].name.Contains(".!Root"))
    62.                 {
    63.                     root = (bonesList[i].transform);
    64.                 }
    65.             }
    66.         }
    67.  
    68.    
    69.         //Attach FBBIK to obj
    70.         FullBodyBipedIK ik = obj.AddComponent<FullBodyBipedIK>();
    71.         //FullBodyBipedIK ik = GameObject.Instantiate(obj).AddComponent<FullBodyBipedIK>();
    72.  
    73.         //Auto detect references
    74.         BipedReferences references = new BipedReferences();
    75.         BipedReferences.AutoDetectReferences(ref references, ik.transform, BipedReferences.AutoDetectParams.Default);
    76.         ik.SetReferences(references, null);
    77.  
    78.         //Set some solver parameters for HeadEffector
    79.         ik.solver.leftHandEffector.maintainRelativePositionWeight = 0.75f;
    80.         ik.solver.rightHandEffector.maintainRelativePositionWeight = 0.75f;
    81.  
    82. //Set limb orientations for grounderIK
    83.         ik.solver.SetLimbOrientations(BipedLimbOrientations.MaxBiped); // The limb orientations definition for 3ds Max Biped skeletons
    84.  
    85.  
    86.         //Add GrounderFBBIK
    87.         GrounderFBBIK grounderFBBIK = obj.AddComponent<GrounderFBBIK>();
    88.         grounderFBBIK.solver.layers = LayerMask.NameToLayer("Everything");
    89.         grounderFBBIK.weight = 1.0f;
    90.  
    91.  
    92.         //Create  headEffectorGO
    93.         GameObject headEffectorGO = new GameObject();
    94.         headEffectorGO.name = ik.gameObject.name + " Head Effector";
    95.         headEffectorGO.transform.position = references.head.position;
    96.         headEffectorGO.transform.rotation = references.head.rotation;
    97.  
    98.         //Add FBBIKHeadEffector
    99.         FBBIKHeadEffector headEffector = headEffectorGO.AddComponent<FBBIKHeadEffector>();
    100.         headEffector.ik = ik;
    101.  
    102.         //Asign bend bones
    103.         FBBIKHeadEffector.BendBone spine = new FBBIKHeadEffector.BendBone();
    104.         spine.transform = references.spine[0];
    105.         spine.weight = 1f;
    106.  
    107.         FBBIKHeadEffector.BendBone chest = new FBBIKHeadEffector.BendBone();
    108.         chest.transform = references.spine[1];
    109.         chest.weight = 0.75f;
    110.  
    111.         headEffector.bendBones = new FBBIKHeadEffector.BendBone[2] {
    112.                   spine,
    113.                   chest
    114.               };
    115.  
    116.         //set weight
    117.         headEffector.bendWeight = 1f;
    118.         headEffector.positionWeight = 1f;
    119.         headEffector.rotationWeight = 1f;
    120.  
    121.         //Add LookAtIK
    122.         lookAtIK = obj.AddComponent<LookAtIK>();
    123.         lookAtIK.solver.SetChain(joint_Torso, joint_Head, joint_Eyes, root);
    124.     }
     
    Last edited: Dec 29, 2017
  28. Bitboys

    Bitboys

    Joined:
    Apr 22, 2015
    Posts:
    156
    Hello again. I tried the Debug.log and it´s showing on the console but the ik is still not working.
    I also tried again with photontransformview on the joints but nothing happens, tried to send Rpc and again with my script streaming the rotations.
    There's something I'm not doing well or something I'm forgetting. :(
     
  29. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hey,
    If you are streaming rotations directly, keep in mind they need to be applied not in OnPhotonSerializeView, but in LateUpdate. Otherwise Mecanim just owerwrites that.

    About that AimIK not doing anything, I really can't guess what it might be, could you run another log operation for me please? This time, add this to IKSolverAim.cs at line 154 (end of protected override void OnUpdate()):

    Code (CSharp):
    1. Debug.Log("AimIK Update");
    2.             Debug.Log("IKPositionWeight: " + IKPositionWeight);
    3.             Debug.Log("Pole Weight: " + poleWeight);
    4.             Debug.Log("Clamp Weight: " + clampWeight);
    5.             Debug.Log("Axis: " + axis);
    6.             Debug.Log("Bone Count: " + bones.Length);
    7.             for (int i = 0; i < bones.Length; i++) {
    8.                Debug.Log("Bone " + i + ": " + bones[i].transform.name + ", Weight: " + bones[i].weight);
    9.             }
    Best,
    Pärtel
     
  30. Bitboys

    Bitboys

    Joined:
    Apr 22, 2015
    Posts:
    156
    Yes, the aimik rotation was launched from lateUpdate.

     
  31. Kagyu

    Kagyu

    Joined:
    Mar 5, 2016
    Posts:
    96
    I need someone's help.
    How do I script to give Spine Effector (marked in red in the attached picture) to my grounderFBBIK component when I attach it to my model by script?
    I have been trying to script it by myself for last couple of hours but still having no luck...

    Thanks!
     

    Attached Files:

  32. LordHorusNL

    LordHorusNL

    Joined:
    Jun 22, 2017
    Posts:
    12
    I'm using VRIK and was wondering if there is a way to have the arms of my character scale/stretch when the controller is just out of reach of the IK setup?

    I already scale the arms to the right length at the start of my game, however sometimes when the player reaches far enough away the IK Solver setup will stop short of the controllers position, especially when crouching.

    Also will the Playmaker actions be updated to include VRIK? "Setting new hand targets"

    Thanks
     
    Last edited: Jan 1, 2018
  33. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hey,
    Based on that log, AimIK seems to work alright, I mean it gets called after the solver has updated. Perhaps there is something overwriting it, like calling animator.Update() after AimIK solves or something like that. Can't really tell without seeing the project myself.

    Code (CSharp):
    1. public GrounderFBBIK grounder;
    2.  
    3.     void Start() {
    4.         grounder.spine = new GrounderFBBIK.SpineEffector[5];
    5.  
    6.         grounder.spine[0] = new GrounderFBBIK.SpineEffector();
    7.         grounder.spine[0].effectorType = FullBodyBipedEffector.LeftShoulder;
    8.         grounder.spine[0].horizontalWeight = 1f;
    9.         grounder.spine[0].verticalWeight = 0.3f;
    10.  
    11.         grounder.spine[1] = new GrounderFBBIK.SpineEffector();
    12.         grounder.spine[1].effectorType = FullBodyBipedEffector.RightShoulder;
    13.         grounder.spine[1].horizontalWeight = 1f;
    14.         grounder.spine[1].verticalWeight = 0.3f;
    15.  
    16.         grounder.spine[2] = new GrounderFBBIK.SpineEffector();
    17.         grounder.spine[2].effectorType = FullBodyBipedEffector.Body;
    18.         grounder.spine[2].horizontalWeight = -0.3f;
    19.         grounder.spine[2].verticalWeight = 0.3f;
    20.  
    21.         grounder.spine[3] = new GrounderFBBIK.SpineEffector();
    22.         grounder.spine[3].effectorType = FullBodyBipedEffector.LeftHand;
    23.         grounder.spine[3].horizontalWeight = 0.5f;
    24.  
    25.         grounder.spine[4] = new GrounderFBBIK.SpineEffector();
    26.         grounder.spine[4].effectorType = FullBodyBipedEffector.RightHand;
    27.         grounder.spine[4].horizontalWeight = 0.5f;
    28.     }
    Don't forget to add
    Code (CSharp):
    1. using RootMotion.FinalIK;
    However, if you add this constructor to like 54 in GrounderFBBIK.cs:
    Code (CSharp):
    1. /// <summary>
    2.             /// Initializes a new instance of the <see cref="RootMotion.FinalIK.GrounderFBBIK+SpineEffector"/> class.
    3.             /// </summary>
    4.             /// <param name="effectorType">Effector type.</param>
    5.             /// <param name="horizontalWeight">Horizontal weight.</param>
    6.             /// <param name="verticalWeight">Vertical weight.</param>
    7.             public SpineEffector(FullBodyBipedEffector effectorType, float horizontalWeight, float verticalWeight) {
    8.                 this.effectorType = effectorType;
    9.                 this.horizontalWeight = horizontalWeight;
    10.                 this.verticalWeight = verticalWeight;
    11.             }
    Then you'll be able to write in nice and clean like this:
    Code (CSharp):
    1. grounder.spine = new GrounderFBBIK.SpineEffector[5] {
    2.             new GrounderFBBIK.SpineEffector(FullBodyBipedEffector.LeftShoulder, 1f, 0.3f),
    3.             new GrounderFBBIK.SpineEffector(FullBodyBipedEffector.RightShoulder, 1f, 0.3f),
    4.             new GrounderFBBIK.SpineEffector(FullBodyBipedEffector.Body, -0.3f, 0.3f),
    5.             new GrounderFBBIK.SpineEffector(FullBodyBipedEffector.LeftHand, 0.5f, 0f),
    6.             new GrounderFBBIK.SpineEffector(FullBodyBipedEffector.RightHand, 0.5f, 0f),
    7.         };
    Hey,
    I already have that developed, please send me your invoice number to support@root-motion.com, I'll send you a solution before the next version is published.

    I don't have any actions for PlayMaker yet, not sure when I can get to doing that, got a ton of other things to finish before that.

    Best,
    Pärtel
     
  34. Kagyu

    Kagyu

    Joined:
    Mar 5, 2016
    Posts:
    96
    Now my FinalIKed actor start climbing stairs more naturally!.
    Thank you so much for your help Partel as always!

    Wow, I am really looking forward to see the next release!
     
  35. Mikekan13

    Mikekan13

    Joined:
    May 30, 2015
    Posts:
    90
    So how would you have the player go up stairs or fall down a cliff?
     
  36. CentViRe

    CentViRe

    Joined:
    Dec 6, 2016
    Posts:
    15
    Hello, i have question how can i set custom animation for legs not in VRIK solution, when moving. Any tutorials, will be great.
     
  37. cameronpennerVR

    cameronpennerVR

    Joined:
    Sep 12, 2017
    Posts:
    4
    Hi @Partel-Lang, I'm using VRIK and having issues with planting feet. They seem to be planing 1ish meters below the objects origin point.

    I'm using only VRIK on a humanoid character setting the head and hands targets. I am not using collider feet planting, so I would expect them to plant at whatever VRIK's local height would be. This is normally the case except...

    When I add a RuntimeAnimatorController to my object, the feet start planting lower than they should. I have masked out everything except the hands (which are the only thing being animated).

    I have fixed this in the past by adding an (full body included in mask) animation that seemed to "set the default positions". But that was with a specific object. I am now using generic mecanim animations that are injected to the animator controller of any character I choose. Which means I can not set the default position based on the mesh's avatar, since the avatar is not the default mecanim humanoid.

    The distance downward seems to be somewhat arbitrary, and I'm not sure where it's being set. Could you point me in the right direction to getting this fixed? I love Final IK, but I've been struggling with this one thing for quite some time now.

    Thanks for any insight you can spare!
     
  38. cameronpennerVR

    cameronpennerVR

    Joined:
    Sep 12, 2017
    Posts:
    4
    I solved it! (Been working at this for a while, and of course solve it right after asking o_O)

    I got rid of all my masks, they didn't help. The problem is that the default mecanim pose with no changes is the half fetal position pose, not a T-Pose. This results in the feet being part way into the ground which was my guess. I editing my "Default Pose" animation to implement a T-Pose to override the halfway in the ground half fetal position pose.

    To do this, I opened the animation on top of a humanoid character. Then I applied my generic animator controller and opened the default pose. I copied the mecanim animation muscle settings from another model I had that had a T-Pose in part of an animation. Since this is generic human muscle controls, it manages to apply these transformations to other models too if that makes any sense.

    I assume this is all because it uses the difference of the feet position to know how far down the "ground" is relative to the model. So if there were like, spikes on the bottom of your shoes, they could stick into the ground, rather than floating above.
     
  39. SteveB

    SteveB

    Joined:
    Jan 17, 2009
    Posts:
    1,451
    Hey guys!

    Regarding VRIK, is it possible to truncate the body, and only use it for the arms/hands?

    Rather than 'only hands', I'd like the presence of the arms, even if just the forearms, but not the possible overhead of tracking IK for the rest of the body that won't be there.

    Thanks all! :D

    -Steven
     
    Bamfax likes this.
  40. wirelessdreamer

    wirelessdreamer

    Joined:
    Apr 13, 2016
    Posts:
    134
    Thanks for all the great support along the way, you've got the best support of anything on the asset store.

    I've been having a hard time getting VRIK movement not looking really choppy, Could you add an example VRIK movement scene with touchpad movement, that for lower body movement it plays a run/walk animation based on movement speed, keeps legs under the player when head height is above x, and when below x goes to a low crawl type of position. I've seen a number of posts from people having trouble getting smooth movement with vrik, and it would help a ton getting a starting point.
     
  41. Bamfax

    Bamfax

    Joined:
    Jun 12, 2016
    Posts:
    52
    Hi Everyone,

    I have a VR scene where a humanoid models' hands are moved by the Vive controller acting as target for the hands. Using VRIK, I get a twisting at the wrists, where the arms are not following as much the hand rotation as they would naturally. Using FBBIK on the same setup, it works out fine. Does someone have an idea on how to get this to work on VRIK as well - is it maybe possible to constrain the underarm to Z rotate with the hands?

    Hands_FinalIK.jpg

    And the short arm stretching challenge also did catch up to me. With my arms being longer than the ones of the player model, the vive controllers are having a good time floating freely in space somewhat away from of the hands, when the arms are fully stretching out. Also arm reach seems to differ a little more than it naturally would, depending on the direction to where the hand is stretched out (sideways same body side, sideways opposite body side). In short, I would think I cannot get around stretching the arms to the necessary length. Is there a recommended solution to that yet? Searching the thread, I found Pärtels statement from Nov 2016 - is that still the way to do it?

    "Character arms can be stretched by multiplying the localPositions if the forearm and hand bones in LateUpdate. any value greater than 1 will stretch arms longer, VRIK will adapt to that, but there is no automatic arm stretching yet."

    Thanks and cheers,
    Olli
     
  42. BernieRoehl

    BernieRoehl

    Joined:
    Jun 24, 2010
    Posts:
    81
    Quick question... and hopefully an easy one. :)

    I'm making my character sit in a chair. I create an empty and position it on the seat of the chair, and set that as the pelvis target with a pelvis position weight of 1. I also create an empty for each foot, and I position them accordingly. I set them as the targets for the left leg and right leg, and set their position weights to 1. I also set the locomotion weight to zero.

    Code (CSharp):
    1.  
    2.                 vrik.solver.spine.pelvisTarget = seatTarget.transform;
    3.                 vrik.solver.spine.pelvisPositionWeight = 1;
    4.                 vrik.solver.spine.pelvisRotationWeight = 1;
    5.                 vrik.solver.spine.rotationWeight = 0;
    6.                 vrik.solver.leftLeg.target = leftFootTarget.transform;
    7.                 vrik.solver.leftLeg.positionWeight = 1;
    8.                 vrik.solver.rightLeg.target = rightFootTarget.transform;
    9.                 vrik.solver.rightLeg.positionWeight = 1;
    10.                 vrik.solver.locomotion.weight = 0;
    11.  
    Unfortunately, my character's right leg keeps shifting:



    Any idea what I'm missing?
     
    Last edited: Jan 7, 2018
  43. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    @Partel-Lang
    Hello, up until now I was prototyping my game with basic animations which was fine so far.
    Now I'm thinking about using/buying Final IK for some animation things that are getting way more difficult than I want to deal with (aiming the head, ...)

    For prototyping so far I am using two simple assets from the asset store and I would like to know if Final IK can either work with them or better even completely replace them.

    1) The first thing I'm using is "DynamicBone" for wings, tails, pouches some characters, long hair, etc... and that works really well so far.

    2) The second asset is "MecFootPlacer" which you add to the feet and then it raycasts every frame to make sure the feet don't slip while walking/running, and it also perfectly places foot/tip/heel on the ground (so when there are obstacles, little stones, ... it the character has their foot placed nicely ontop of them without clipping into the models).

    So my questions are:
    - Can Final IK do those things as well?
    - How much work is it to set those things up?
    - If it can't, is there a way to make it work nicely together with the other two assets?
     
  44. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hey, sorry guys for the way, I caught a nasty vomit virus :eek:

    Hey,
    Did you mean by going up the stairs by using the trackpad/thumbstick or going up the stairs when physically stepping forward with a staircase in front of you?

    The former would be quite simple, just move the root of the character as you would a normal character controller and the capsule collider on it makes it follow the terrain/stairs up and down. If the tracking space is parented to the root of the character, it will also move your view point.

    The latter is more difficult to solve, I mean if you have the entire tracking space parented to the character, but you also need the HMD to be able to move the character, there will be a circular dependency issue. There is also the issue of motion sickness if your player takes a physical step forward on a flat floor, but the height of the camera is moved up or down based on the terrain. Bottom line is, there is no "right" way to do this, it is impossible to match real world flat floor to virtual terrain seamlessly.
    You could adjust the center of the character controller's collider to follow the HMD:
    Code (CSharp):
    1. void FixedUpdate () {
    2.         Vector3 center = transform.InverseTransformPoint(centerEyeAnchor.position);
    3.         center.y = collider.center.y;
    4.         collider.center = center;
    5.     }
    So if the player steps forward and there is a slope in front of him, it will move the camera up as well. Also, if the player is standing next to a wall, trying to lean into the wall would give him the sensation of pushing the entire world away from him or rather leaning against a wall with his head and his feet sliding back on a slippery surface as he leans further. At least there would be no looking/walking through scene geometry.

    Anyway, as I said, there is no "right" way to solve this, so your ideas are as good as mine.

    Hey,
    If you set VRIK locomotion weight to 0, your legs will be free to follow whatever animation playing in Mecanim. I have a WIP demo for animated locomotion, it's quite raw and you could do better with better locomotion animation, such as Kubold's Movement Animset. It's still a WIP bu should get you started at least.

    Hey,

    Just use 2 LimbIK components for the arms.

    Hey,
    Please see the answer to CentViRe above.

    Hey,
    About the twisting issue, please see the "VRIK (Twist Relaxer)" demo and read the comments on the README gameobject in it.

    About the stretching, please send me your invoice number to support@root-motion.com and I'll give you a solution until I get the next version out there (finally, long overdue, I know).

    Hey,
    Looks like the animation playing on him has the right knee flipped at some point. Does it happen if you switch out the animation clip with something else?
    If it's the animation, it could probably be fixed if you go to the Muscles & Settings in the Avatar Cofiguration and reduce the max value of Lower Leg Stretch for the Left and Righ Leg under Per-Muscle Settings.

    Hey,
    I've had some clients ask about some problems with Dynamic Bone and the trick is making Dynamic Bone update after the Final IK components using the Script Execution Order. I haven't heard of any other problems.

    About MecFootPlacer, haven't tried that, but Final IK does contain the same kind of a solution, called the Grounder.
    In that video, GrounderFBBIK is used, that employs the FullBodyBipedIK component, but if you don't need full body IK for some other stuff, go with GrounderIK and two LimbIK components for the legs. There are multiple Grounder components in the package, they can be used on all kinds of characters, including spiders, bots and quadrupeds.

    Cheers,
    Pärtel
     
    shiena and dadude123 like this.
  45. BernieRoehl

    BernieRoehl

    Joined:
    Jun 24, 2010
    Posts:
    81
    You were absolutely right -- it was the animation. I swapped it out for a different one and the problem went away.

    Thanks, Pärtel !
     
  46. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    397
    I'm having an issue where my left arm gets a weird rotation on it randomly as I play the game. Is there a reset or something I can call periodically to ensure it's not twisted up? This is the script I'm using and I think the issue lies somewhere in there.



    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4. using RootMotion.FinalIK;
    5. using Goon;
    6. using RootMotion;
    7.  
    8. public class SecondHandOnGun : MonoBehaviour
    9. {
    10.     public AimIK aim = null;
    11.     public FullBodyBipedIK ik;
    12.     public LookAtIK look;
    13.     [SerializeField]
    14.     private Transform lookTarget;
    15.     private Transform staticLookTarget;
    16.     public Recoil recoil;
    17.     private Quaternion rightHandRotation;
    18.     public Vector3 gunHoldOffset;
    19.     public Vector3 leftHandOffset;
    20.  
    21.     [SerializeField]
    22.     private Transform pistolTransform;
    23.  
    24.     private IKEffector leftHand { get { return ik.solver.leftHandEffector; } }
    25.     private IKEffector rightHand { get { return ik.solver.rightHandEffector; } }
    26.  
    27.     //private Quaternion leftHandRotationRelative;
    28.     private Vector3 leftHandPosRelToRightHand;
    29.     private Quaternion leftHandRotRelToRightHand;
    30.     private PlayerAim pAim;
    31.     // Use this for initialization
    32.     void Start ()
    33.     {
    34.         //AimIK [] aims = GetComponents<AimIK>();
    35.         //aim = aims[1];
    36.         //ik.solver.OnPreRead += OnPreRead;
    37.         aim.enabled = false;
    38.         //ik.enabled = false;
    39.         look.enabled = false;
    40.         //aim.Disable();
    41.         //ik.Disable();
    42.         //look.Disable();
    43.  
    44.  
    45.         //this is to prevent elbow from turning inside out when shooting
    46.         ik.solver.SetLimbOrientations(BipedLimbOrientations.UMA);
    47.         //BipedLimbOrientations blo = new BipedLimbOrientations(new BipedLimbOrientations.LimbOrientation())
    48.         //ik.solver.SetLimbOrientations();
    49.         pAim = ObjectReferences.playerController.GetComponent<PlayerAim>();
    50.         staticLookTarget = ObjectReferences.player.GetComponentInChildren<StaticLookTarget>().transform;
    51.  
    52.         //ik.solver.OnPostUpdate += OnPostFBBIK;
    53.     }
    54.  
    55.     void OnEnable()
    56.     {
    57.         //look.solver.headWeight = 1f;
    58.         look.solver.target = lookTarget;
    59.         look.enabled = false;
    60.         aim.enabled = true;
    61.  
    62.         if (aim != null && aim.solver != null)
    63.         {
    64.             aim.solver.transform = pistolTransform;
    65.         }
    66.  
    67.         if (ik != null) ik.solver.OnPreRead += OnPreRead;
    68.        
    69.  
    70.         //ik.solver.OnPostUpdate += OnPostFBBIK;
    71.     }
    72.  
    73.     void OnDisable()
    74.     {
    75.         //look.solver.headWeight = 0f;
    76.         look.solver.target = staticLookTarget;
    77.         look.enabled = true;
    78.         aim.enabled = false;      
    79.  
    80.         leftHand.positionWeight = 0f;
    81.         rightHand.positionWeight = 0f;
    82.         //ik.enabled = false;
    83.         aim.solver.transform = null;
    84.         if (ik != null) ik.solver.OnPreRead -= OnPreRead;
    85.        
    86.  
    87.         //ik.solver.OnPostUpdate -= OnPostFBBIK;
    88.  
    89.     }
    90.  
    91.     // Update is called once per frame
    92.     void LateUpdate ()
    93.     {
    94.         // Find out how the left hand is positioned relative to the right hand rotation
    95.         //Vector3 toLeftHand = leftHand.bone.position - rightHand.bone.position;
    96.         //Vector3 toLeftHandRelative = rightHand.bone.InverseTransformDirection(toLeftHand);
    97.         //rightHandRotation = ik.references.rightHand.rotation;
    98.  
    99.         Read();
    100.  
    101.         //ik.solver.SetLimbOrientations(BipedLimbOrientations.UMA);
    102.  
    103.         // Rotation of the left hand relative to the rotation of the right hand
    104.         //leftHandRotationRelative = Quaternion.Inverse(rightHand.bone.rotation) * leftHand.bone.rotation;
    105.  
    106.         aim.solver.IKPosition = look.solver.IKPosition;
    107.         aim.solver.Update();
    108.  
    109.         rightHandRotation = ik.references.rightHand.rotation;
    110.  
    111.         Vector3 rightHandOffset = ik.references.rightHand.rotation * gunHoldOffset;
    112.         ik.solver.rightHandEffector.positionOffset += rightHandOffset;
    113.  
    114.         //if (recoil != null)
    115.         //{
    116.         if (!pAim.gun.isDrawing && !pAim.gunScript.reloading && !pAim.gunScript.overheating && !ObjectReferences.playerController.isRolling && !ObjectReferences.playerController.isJumping)
    117.         {
    118.             recoil.SetHandRotations(rightHandRotation * leftHandRotRelToRightHand, rightHandRotation);
    119.         }
    120.         else
    121.         {
    122.             recoil.SetHandRotations(leftHand.bone.rotation, rightHandRotation);
    123.         }
    124.         //}
    125.  
    126.         ik.solver.Update();
    127.  
    128.         //// Position the left hand on the gun
    129.         //leftHand.position = rightHand.bone.position + rightHand.bone.TransformDirection(leftHandPosRelToRightHand);
    130.         //leftHand.positionWeight = 1f;
    131.  
    132.         ////// Making sure the right hand won't budge during solving
    133.         //rightHand.position = rightHand.bone.position;
    134.         //rightHand.positionWeight = 1f;
    135.         //ik.solver.GetLimbMapping(FullBodyBipedChain.RightArm).maintainRotationWeight = 1f;
    136.        
    137.         // Rotating the hand bones after IK has finished
    138.         if (recoil != null)
    139.         {
    140.             ik.references.rightHand.rotation = recoil.rotationOffset * rightHandRotation;
    141.             if (!pAim.gun.isDrawing && !pAim.gunScript.reloading && !pAim.gunScript.overheating && !ObjectReferences.playerController.isRolling && !ObjectReferences.playerController.isJumping)
    142.             {
    143.                 ik.references.leftHand.rotation = recoil.rotationOffset * rightHandRotation * leftHandRotRelToRightHand;
    144.             }
    145.         }
    146.         else
    147.         {
    148.             ik.references.rightHand.rotation = rightHandRotation;
    149.             if (!pAim.gun.isDrawing && !pAim.gunScript.reloading && !pAim.gunScript.overheating && !ObjectReferences.playerController.isRolling && !ObjectReferences.playerController.isJumping)
    150.             {
    151.                 ik.references.leftHand.rotation = rightHandRotation * leftHandRotRelToRightHand;
    152.             }
    153.         }
    154.  
    155.         // Rotate the head
    156.         look.solver.Update();
    157.     }
    158.  
    159.     private void Read()
    160.     {
    161.         // Remember the position and rotation of the left hand relative to the right hand
    162.         leftHandPosRelToRightHand = ik.references.rightHand.InverseTransformPoint(ik.references.leftHand.position);
    163.         //leftHandRotRelToRightHand = Quaternion.Inverse(rightHand.bone.rotation) * leftHand.bone.rotation;
    164.         leftHandRotRelToRightHand = Quaternion.Inverse(ik.references.rightHand.rotation) * ik.references.leftHand.rotation;
    165.     }
    166.  
    167.     // Final calculations before FBBIK solves. Recoil has already solved by, so we can use it's calculated offsets.
    168.     // Here we set the left hand position relative to the position and rotation of the right hand.
    169.     private void OnPreRead()
    170.     {
    171.         Quaternion r = recoil != null ? recoil.rotationOffset * rightHandRotation : rightHandRotation;
    172.        
    173.         if(!pAim.gun.isDrawing && !pAim.gunScript.reloading && !pAim.gunScript.overheating && !ObjectReferences.playerController.isRolling && !ObjectReferences.playerController.isJumping)
    174.         {
    175.             Vector3 leftHandTarget = ik.references.rightHand.position + ik.solver.rightHandEffector.positionOffset + r * leftHandPosRelToRightHand;
    176.             ik.solver.leftHandEffector.positionOffset += leftHandTarget - ik.references.leftHand.position - ik.solver.leftHandEffector.positionOffset + r * leftHandOffset;
    177.         }      
    178.     }
    179.  
    180.     // Cleaning up the delegates
    181.     void OnDestroy()
    182.     {
    183.         if (ik != null) ik.solver.OnPreRead -= OnPreRead;
    184.     }
    185.  
    186.     // Rotate left hand after FBBIK has finished
    187.     //private void OnPostFBBIK()
    188.     //{
    189.     //    leftHand.bone.rotation = rightHand.bone.rotation * leftHandRotationRelative;
    190.     //}
    191. }
    192.  
    193.  
     
  47. newfinalflashers

    newfinalflashers

    Joined:
    Mar 1, 2014
    Posts:
    27
    From what I can guess: I think the character's joints are not defined well enough. Partel discusses the solution to this in his first video. You can check if the joints are directionally sound by selecting the character with FBBIK (Make sure the component drop down in open so you can see the gizmos in the scene). If their are any yellow or red squares bend the joints until the squares turn blue.next follow this by checking the arrow behind the left elbow and shoulder. They should be pointing away from their bend direction. If they are not pointing in the direction then rotate the joints so the arrows are pointing opposite the intended bend direction.
     
  48. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Thanks! Yes, that is usually the case, but here, WightWale is calling
    Code (CSharp):
    1. ik.solver.SetLimbOrientations(BipedLimbOrientations.UMA);
    which defines the bone orientations and bend directions for a rig specific to UMA.
    Is this an UMA character? Just asking because I don't see the code that adds FBBIK and other IK in Start.
     
  49. CentViRe

    CentViRe

    Joined:
    Dec 6, 2016
    Posts:
    15
    Very Thanks for Replying, have another request or question about integration with VRTK Asset. It will be great, like Interaction, locomotion and so on.
    Also will be glad buying this solutions.
     
  50. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hey,
    Sure, made this little integration demo scene for another customer recently.
    Best,
    Pärtel
     
    CentViRe likes this.