Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

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

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

  1. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,058
    Hey,
    Is the second floor on another layer perhaps? Looks like raycasting does not find the floor.
     
  2. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,058
    Hey, only this:
    Code (CSharp):
    1. /// <summary>
    2.     /// Relaxes the twist rotation of this Transform relative to a parent and a child Transform, using their initial rotations as the most relaxed pose.
    3.     /// </summary>
    4.     public class TwistRelaxer : MonoBehaviour {
    5.        
    6.         [Tooltip("The weight of relaxing the twist of this Transform")]
    7.         [Range(0f, 1f)] public float weight = 1f;
    8.  
    9.         [Tooltip("If 0.5, this Transform will be twisted half way from parent to child. If 1, the twist angle will be locked to the child and will rotate with along with it.")]
    10.         [Range(0f, 1f)] public float parentChildCrossfade = 0.5f;
    11.  
    12.         [Tooltip("The parent Transform, does not need to be the actual transform.parent.")]
    13.         public Transform parent;
    14.  
    15.         [Tooltip("The child Transform, does not need to be the direct child, you can skip bones in the hierarchy.")]
    16.         public Transform child;
    17.  
    18.         [Tooltip("The local axis of this Transform that it will be twisted around (the axis pointing towards the parent).")]
    19.         public Vector3 twistAxis = Vector3.right;
    20.  
    21.         [Tooltip("Another axis, orthogonal to twistAxis.")]
    22.         public Vector3 axis = Vector3.forward;
    23.  
    24.         /// <summary>
    25.         /// Rotate this Transform to relax it's twist angle relative to the "parent" and "child" Transforms.
    26.         /// </summary>
    27.         public void Relax() {
    28.             if (weight <= 0f) return; // Nothing to do here
    29.            
    30.             // Find the world space relaxed axes of the parent and child
    31.             Vector3 relaxedAxisParent = parent.rotation * axisRelativeToParentDefault;
    32.             Vector3 relaxedAxisChild = child.rotation * axisRelativeToChildDefault;
    33.            
    34.             // Cross-fade between the parent and child
    35.             Vector3 relaxedAxis = Vector3.Slerp(relaxedAxisParent, relaxedAxisChild, parentChildCrossfade);
    36.            
    37.             // Convert relaxedAxis to (axis, twistAxis) space so we could calculate the twist angle
    38.             Quaternion r = Quaternion.LookRotation(transform.rotation * axis, transform.rotation * twistAxis);
    39.             relaxedAxis = Quaternion.Inverse(r) * relaxedAxis;
    40.            
    41.             // Calculate the angle by which we need to rotate this Transform around the twist axis.
    42.             float angle = Mathf.Atan2(relaxedAxis.x, relaxedAxis.z) * Mathf.Rad2Deg;
    43.            
    44.             // Store the rotation of the child so it would not change with twisting this Transform
    45.             Quaternion childRotation = child.rotation;
    46.            
    47.             // Twist the bone
    48.             transform.rotation = Quaternion.AngleAxis(angle * weight, transform.rotation * twistAxis) * transform.rotation;
    49.            
    50.             // Revert the rotation of the child
    51.             child.rotation = childRotation;
    52.         }
    53.  
    54.         private Vector3 axisRelativeToParentDefault, axisRelativeToChildDefault;
    55.        
    56.         void Start() {
    57.             // Axis in world space
    58.             Vector3 axisWorld = transform.rotation * axis;
    59.  
    60.             // Store the axis in worldspace relative to the rotations of the parent and child
    61.             axisRelativeToParentDefault = Quaternion.Inverse(parent.rotation) * axisWorld;
    62.             axisRelativeToChildDefault = Quaternion.Inverse(child.rotation) * axisWorld;
    63.         }
    64.  
    65.         void LateUpdate() {
    66.             Relax();
    67.         }
    68.     }
    Add this script to the Script Execution Order, make it update after all Final-IK components.
    Its a script I made originally for relaxing twist bones, but I imagine it can be used to fix weird twist errors on other bones too like shoulders. Read the tooltips to know what the axes and other variables mean.

    Best,
    Pärtel
     
  3. Morpheus

    Morpheus

    Joined:
    Feb 2, 2014
    Posts:
    13
    Thanks, I will look into that. Does it need to be attached to each bone that is twisting weirdly?
    Also, I was wondering if there was any way with FBBIK to ensure that the model does not interpenetrate itself? I was looking at using constraints for this, but it says in the documentation that additional constraints are not supported for FBBIK and it has all the necessary ones built it. However if I place the target for the hand inside the torso, the model will literally insert its hand into its torso, and even for targets where there is a solution without interpenetration, it will sometimes insert its elbow into its face.
    Any help would be greatly appreciated.
     
  4. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,058
    Hi,
    Yes, use it on weirdly twisting bones.

    FBBIK was designed for making small to medium adjustments on the animation, which is sufficient for most use cases in games, so it's not really a posing tool. It was designed as such to minimize the cost on performance, to get what has to be done done as quickly as possible. Interpenetration avoidance would require multiple passes of solving so that's where it becomes pointless as people don't usually have that much CPU budget to spend on stuff like that. That's where the recommendation of keeping the effectors out of the body in the first place comes from.

    You can assist FBBIK though, by adjusting the pose of the character closer to the solution you are looking for before FBBIK solves. I mean if you know that the upper body is supposed to look towards left/right, you can use AimIK or LookAtIK to solve before FBBIK to get the character to a pose that requires less bone twisting from FBBIK.

    Pärtel
     
  5. Ragoo

    Ragoo

    Joined:
    Feb 15, 2014
    Posts:
    78
    Did you ever end up releasing that IK keyframe baker (e.g. using effector offsets on existing clips)? I cannot seem to find the Youtube video anymore either so I'm assuming you had to scrap the feature.

    Still greatly enjoying using the asset and only now am finding great use for this particular feature.. cheers
     
  6. shawnblais

    shawnblais

    Joined:
    Oct 11, 2012
    Posts:
    218
    Hi Partel, is there a rough ETA for the VR Rig? Just wondering if we're looking at weeks, or months?
    Cheers,
     
  7. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,058
    Hey,
    I had to drop it, at least until the API for creating humanoid animation is opened up. Otherwise it would require exporting to DAE/FBX and reimporting as humanoid, which would be a gigantic mess. In the meanwhile, you might want to take a look at Skele, looks solid.

    Hey,
    Yes, I'm planning to release it by Oculus Connect 3, beginning of Oct.

    Cheers,
    Pärtel
     
  8. dornseif

    dornseif

    Joined:
    Aug 25, 2016
    Posts:
    7
    QUESTION FINAL IK - GROUNDER - DANCE ANIMATION - BOTH FEET OFF THE GROUND

    How would I use Final IK - Grounder FBBIK Script to cause the models pelvis (whole body) to move toward the ground and her feet to stay on the ground. Currently the animation incorrectly pulls the characters feet up off the ground so she dances in air. I tried tweaking various settings with no desired change. If one foot stays planted then she should indeed not change position but when both come off the ground she should move down. squatting.

    Tom

    PS, some authors offer discount when you buy there apps on other apps I have been looking at puppet. Since I purchased Final IK do you consider offering discount to loyal customers :)
     
  9. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,058
    Hi,
    Grounder works by considering 0 y in the animation clip as ground level, so it will offset the feet based on the vertical distance of the raycast hit from the character's root. It is the working principle of the whole thing so if there is a problem already in the animation, Grounder can't fix it.

    In the animation import settings you have Root Transform Position (Y) and under that an Offset. Can't you use that to bring the animation down?

    About the discount, I had it at first, but the AS merged the ratings and reviews between the 2 packages, considering them as one. I asked them what should I do, they just said remove it, it was meant for upgrades from v1 to v2 and stuff like that.

    Best,
    Pärtel
     
  10. dornseif

    dornseif

    Joined:
    Aug 25, 2016
    Posts:
    7
    Thanks Pärtel,
    You are correct I had an error in the animation. I fixed it on import and all is working.
    I have only scratched the surrface so far, but I am impatient an will probably purchase your puppet before I finish learning all I can do with Final IK. I came across the kissing rig in the demos thats really cool, and with so little script.

    I am playing with importing models from Sourcefilmmaker and VR (Vive) Its really for my own amusement right now, I have the characters grabbing my headset and my controllers, but I keep going back and watching your video on the puppet behavior and I really got to have it. All the cool things I could do with that.

    Thanks again for the quick reply, Tom
     
    Partel-Lang likes this.
  11. nghiattran

    nghiattran

    Joined:
    Aug 27, 2016
    Posts:
    2
    Hi Partel.

    I am trying to use FinalIK to make hand-poses on guns but having a problem that it twists the arm and forearm like in the screen shot. The one on the right uses hand pose. Can you give me some advice?
     

    Attached Files:

  12. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,058
    Hi,
    Yeah, don't use rotation weights on the effectors. They can mess up the elbow direction in some cases. Rather just rotate the hand bone directly after IK has solved:

    Code (CSharp):
    1. ik.solver.leftHandEffector.bone.rotation = leftHandTargetRotation;
    If you don't want to use the OnPostUpdate delegate, you can rotate the hand bone in LateUpdate, but make sure "Maintain Hand Rot" is 1 in the FBBIK inspector for that limb.
     
  13. impi2

    impi2

    Joined:
    Jul 3, 2015
    Posts:
    43
    Hi,

    I'd like to understand how to use this with UMA characters, particularly the interactive posing etc. From what i can see after browsing forum and videos, its very useful to create an interactive action.... like the video opening doors etc.

    But i cant see how one would do that with UMA ... as the characters are built in code.

    So in the video theres a step to duplicate the character, then move the fingers in edit mode and copy the component values back to the sphere etc. But how to go about that with UMA?

    Is there some included tool for doing it?
    There must be some way as i see users like Whippet have created UMA interactions, and UMA is very popular.
     
  14. ranzq_

    ranzq_

    Joined:
    Apr 28, 2015
    Posts:
    4
    Hi,

    I'm setting up limited joints using Rotation Limit Hinges. Is it ok to use multiple Hinge components on a single GameObject? It seems to work fine but I can't rotate the visual aid (there's this "Rotate display 90 degrees" button), it only rotates one of them. Reason I'm using two components is that I need different limits for each axis and I was wondering if this is the proper way to do that.

    UPDATE: Changing zeroAxisDisplayOffset visible allows me to modify them separately.

    UPDATE2: With CCDIK or FABRIK the joint only uses the first rotation limit. So I guess I need to make a parent for the joint to handle the secondary rotation.
     
    Last edited: Aug 31, 2016
  15. boogen

    boogen

    Joined:
    Nov 21, 2013
    Posts:
    1
    Hi Partel!

    I want to make a mechanic similar to the main character in Steppy Pants. I've been looking for ways to do it and I wonder if Puppet Master is the way to go. Is it possible with Puppet Master?

     
  16. Partel-Lang

    Partel-Lang

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

    There is a section about setting up UMA in the FBBIK User Manual page.
    About making targets, you could for example play the scene, have UMA create the character for you, then copy it's hand bone in play mode, stop play mode an paste in the editor.

    Hey,
    Yes, make a parent or use another rotation limit type, such as RotationLimitSpline.

    Hi!
    Yes, it could be done with PuppetMaster I imagine. You could just pin the feet to some targets and attach a joint to the spine that keeps the character "balanced".

    Cheers,
    Pärtel
     
    impi2 likes this.
  17. probitaille

    probitaille

    Joined:
    May 5, 2015
    Posts:
    29
    It's really easy to change your head demo scene to adapt it by using the prefabs of SteamVR plugin. Just need to put the head effector in the steam's camera and set Y position to 0 (that's why other user said the head is floating by default).

    I have set the controllers as hand effectors as said in your last post here and its work well to move my hands (but need a lot of adjustment because of strange arm/shoulder movement) : https://community.unity.com/t5/Asse...ABRIK-CCD-IK-1-0-RELEASED/m-p/2647572#M481839

    But, I'm posting here because I'm searching for the best solution to rotate the whole body when my head and ma hands are oriented in another direction. Do I need to create a character's controller to manage that or is there a way in your plugin?
     
  18. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,058
    Hi,

    You can get the angle of the character's forward relative to the camera:
    Code (CSharp):
    1. Vector3 characterForwardRelativeToCamera = Quaternion.Inverse(cam.transform.rotation) * character.forward;
    2.         float angle = Mathf.Atan2 (characterForwardRelativeToCamera.x, characterForwardRelativeToCamera.z) * Mathf.Rad2Deg;
    Then use it to set a turn value in the Animator that plays a turn on spot animation with root motion.
    Also you can use it to clamp the range of rotation of the character relative to the camera:

    Code (CSharp):
    1. if (Mathf.Abs(angle) > Mathf.Abs(maxAngle)) {
    2.                 float a = angle - maxAngle;
    3.                 if (angle < 0f) a = angle + maxAngle;
    4.                 character.rotation = Quaternion.AngleAxis(a, character.up) * character.rotation;
    5.             }
     
    probitaille likes this.
  19. impi2

    impi2

    Joined:
    Jul 3, 2015
    Posts:
    43
    Thank you for reply.
    I tried that with uma already, but it seems when i paste the hand in the editor, all i see is the transform gizmo (i mean root location of hand etc) ... i dont see the bones of fingers etc ... like in your video. So no way to know how hand is wrapped around sphere, or not, to bend the fingers etc. Is there some option to turn it on i'm missing?
     
  20. probitaille

    probitaille

    Joined:
    May 5, 2015
    Posts:
    29
    Thank you for your response.

    I hope that your VRIK tool will be available soon. I'm currently trying to do the same thing as Hover Junker.
     
  21. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,058
    Hey,
    You can add the InteractionTarget component to that hand temporarily, it will draw the bone hierarchy at least.

    Yes, I'm planning to release it by Oculus Connect 3 next month.

    Cheers,
    Pärtel
     
  22. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    420
    Hi, Grounder Ik is too shaky for my character. setup is same as pilot character but pilot character shakes less than my biped. my character uses standard 3d max biped.
     
  23. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    Hello Pärtel,

    I'm currently experimenting with effector offsets. It seems LookAtIK and AimIK are also influenced when setting position offsets, is there any way to keep them on their targets?
     
  24. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,058
    Hi, could you send me that rig? Or a video of the "shakiness"?

    Hi,
    Its probably an update order issue. LookAtIK, AimIK by default update before FBBIK, but you might want to update them the other way around. Try the IKExecutionOrder component.

    Cheers,
    Pärtel
     
    silentneedle likes this.
  25. mwituni

    mwituni

    Joined:
    Jan 15, 2015
    Posts:
    345
    Hi Partel,

    Glad to see this is so actively supported. We bought fIK a while back and starting to use it.

    We are also planning integrating with UMA, as I am sure many teams are. It might be nice to add some sample scripts to help people get started with it - like integrating different components via script with UMA (apart from the short example in the manual).
     
  26. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    Using UMA with FinalIK doesn't differ much, just use the snipped from the example page for the initialisation and go ahead.
     
    Partel-Lang likes this.
  27. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,058
    Thanks for the suggenstion, I put it down to improve UMA support, however it will have to wait until I get VRIK released.
    Cheers,
    Pärtel
     
    mwituni likes this.
  28. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    537
    Hi Partel,

    I'm here again with another question. I have a character set up with FBBIK AIM LOOKAT and Hit reaction working. All fine. But, when i want to enter in ragdoll mode, there is a violent reaction in the ragdoll and falls to the ground faster than it should. Maybe i need to do some other stuff to make a smooth transition... Right now, i just disable all the components and the animator to enable ragdoll.

    Another thing, is that all raycast from the gun are working well, but as soon as i add ragdoll colliders (using unity assistant) the raycasts are flickering theyr positions. I don't know if it is related to Final IK, but just in case...


    Thanks
     
  29. Partel-Lang

    Partel-Lang

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

    When you switch to ragdoll, do it in LateUpdate, after all IK has applied (use Script Execution Order), then disable all IK components.
    Also take a look at the "Ragdoll Utility" demo, there is a helper script for doing ragdoll stuff with IK.

    About the other question, I don't think it is because of FIK but if you paste your raycasting code I might be able to help.

    Cheers,
    Pärtel
     
    Danirey likes this.
  30. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    537
    Thanks Partel.

    I'm using the ragdoll utility and it works fin now. I'll check the code to add force to the impact point on the ragdoll.

    I'm at work now, but as soon as i can will send you the raycast code.


    Thanks a lot as always!
     
  31. mons00n

    mons00n

    Joined:
    Sep 18, 2013
    Posts:
    234
    Hey @Partel-Lang ! I've only been using the grounder components of FinalIK so far but they are fantastic. One issue I've recently encountered is with the GrounderQuadruped on a dragon. I setup all 4 legs, assign the root/pelvis/spine/head like so:

    and upon hitting play he face plants through the floor:

    Any thoughts on why that might be happening? If I only assign the root for instance, he does this for a bit before falling through:


    EDIT:
    tried the same procedure with a bear and got slightly different results:

    however, if I add GrounderIK instead of Quadraped it works fine.
     
    Last edited: Sep 13, 2016
  32. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,058
    Hey,
    Maybe there are some colliders on the dragon that conflict with the grounder's raycasting?
    Also make sure all characters are facing towards the blue axis of their root transform and green is up.
    If that doesn't help, perhaps you could package that stuff up and send a link to support@root-motion.com or PM.

    Cheers,
    Pärtel
     
  33. mons00n

    mons00n

    Joined:
    Sep 18, 2013
    Posts:
    234
    The rotation seems to have done it, thanks! Is the GrounderQuadraped less computationally intensive than the more generic GrounderIK?
     
  34. helgarddebarros

    helgarddebarros

    Joined:
    May 10, 2014
    Posts:
    149
    I added the biped IK to my bipeds, and it worked perfectly fine. When I tried to add the quadroped IK to my animals, I got a message that there are no grounding layers, so I used the grounderIK instead.

    It works perfectly fine most of the time, but occasionally, as in the attached video, it seems to glitch and get all shaky, and my frame rate drops massively.



    Any advice on what to look at to fix this?
     

    Attached Files:

  35. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,058
    Hi,
    The difference in performance is insignificant. The quadruped grounder also rotates the spine of the creature, it can raise/lower the chest of the creature. GrounderIK is for spiders and such, its good for creatures that have all their legs connected to a single pelvis bone.

    Hey,
    The message comes from another grounder than you had selected in that screenshot. You had GrounderBipedIK selected, but in the message log it says it comes from GrounderQuadruped, so I bet you should check that rhino's grounder and set up layers for both it's solver and foreleg solver.

    I'm not sure where the glitch comes from, could you click trough the hierarchy and tell me which gameobject is glitching? It might be an issue with the layer masks set up wrong, the Grounder's raycasts hitting some colliders of the character itself.

    Cheers,
    Pärtel
     
  36. helgarddebarros

    helgarddebarros

    Joined:
    May 10, 2014
    Posts:
    149
    Sorry, my bad, I didn't expand the foreleg solver and add the ground layers for that. Everything fixed now and working smoothly.
     
  37. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    Hey Pärtel,

    I'm currently in the setup of AimIK for multiple weapons. What is the best practice when it comes to positioning the aim transform? In the example you've placed the aim transform of the mp 40 at the start of the barrel, but in my current setup I have the best results when I'm placing the aim transform at the end of the barrel.
     
  38. s_guy

    s_guy

    Joined:
    Feb 27, 2013
    Posts:
    102
    I have a character with GrounderFBBIK and I need some way to see when a foot is near its IK target or near the ground. I could use the heelHit.distance in the GroundingLeg, but that's not part of the public interface. Before I expose that, is there a better way that I'm not seeing?

    Thanks
     
  39. shawnblais

    shawnblais

    Joined:
    Oct 11, 2012
    Posts:
    218
    Hi Partel, can you provide any instructions on how to use FBIKArmBending?

    I'm trying to get a basic VR rig working with head effector + hand effectors. The FBIKArmBending script certain seems to make most poses better, but only for my left arm, the right arm had the elbow revered so it was always pointing forward.
     
  40. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,058
    For multiple weapons, if they are held the same way, I mean if you just need to have an AK47 and a M4 and need to switch without messing up aiming, you can parent the guns to the Aim Transform.
    It doesn't really matter where you place it, depends on the rig, but if it works for you better, its no problem.

    Hi,

    Code (CSharp):
    1. grounder.solver.legs[0].heightFromGround;
    0 is index of the left leg, 1 is right.

    Hi,
    Are you using the exact same values as in the Head Effector (Hand Controllers) demo or some other values?

    Cheers,
    Pärtel
     
  41. rurulesunc

    rurulesunc

    Joined:
    Sep 16, 2016
    Posts:
    1
    Hi Partel -

    Just getting started with FInalIK. I need to drive forearms with IK (not hands) Can you point me in the right direction to get started? Do I need to make a custom IK chain like you show in the mechanical spider tutorial? Any other suggestions?
     
  42. shawnblais

    shawnblais

    Joined:
    Oct 11, 2012
    Posts:
    218
    Ah, sorry, I didn't see those demo's, was only looking under the virtual reality folder. Thanks for the heads up!

    I took that demo and hooked it up the the VIVE, the arms bend properly, but my hands are pointing in the wrong directions. When I create a handEffector, and rotate it to put them in the proper rotation, the right arm works fine, but the left arm gets messed up: after fixing hand rotation, when rotating the left hand counter-clockwise, the left forearm will move clockwise, cause the elbow to move in the wrong direction.

    Any ideas?
     
  43. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    I'm currently trying to position the left hand on a rifle using FBBIK left hand effector with position/rotation weight on. Unfortunately when rotating the hand until the palms points to the top the elbow rotates inside the body. Should I use a bend goal to avoid that or I am doing something wrong?

    p.s. The cause of my last problem with the aim transform of AimIK was related to the execution order. It seems it's better to always update AimIK after FFBIK, otherwise it's possible that AimIK doesn't aims correctly to the target.

    However, when doing this the left hand doesn't follow the weapon anymore, is there any way to update only the left arm in FBBIK our should I add LimbIK to the left arm and update that component after AimIK?
     
    Last edited: Sep 16, 2016
  44. StairfallInstitute

    StairfallInstitute

    Joined:
    Sep 16, 2016
    Posts:
    1
    Hi Partel,

    I understand that I can use a CCD chain to position things, then AimIK to control the rotation but my initial experiments haven't been successful at all - I can't seem to get the final part of the robot arm to aim at the target with or without rotational constraints, even when the pink arrow is pointing in the right direction! If it moves at all it just seems to point in random directions. :S I wonder if somehow the CCD is conflicting with the AimIK?

    Update: I apparently made this work by having the CCD chain go through all the bones of the robot arm, killing the weights of the last 3 axis, and then having AimIK take over for those last 3 bones. Frustratingly AimIK isn't quite rotating the bones enough. Have added a screenshot that shows the problem... the aimik solve looks correct but the bone seems to have a built in 0.5 weight instead of the 1 I've set it to?

    Thanks again!
     

    Attached Files:

    Last edited: Sep 17, 2016
  45. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,406
    Just revisited this code, isVibile does not not work for occluded objects. I wrote a little helper component, sadly it needs to be added to each LOD in group, this will work for both Culled LOD groups and occlusion.

    Code (CSharp):
    1.     public class WillRender : MonoBehaviour {
    2.         private IWillRenderListener listener;
    3.  
    4.         public void SetListener(IWillRenderListener listener) {
    5.             this.listener = listener;
    6.         }
    7.  
    8.         protected void OnWillRenderObject() {
    9.             listener.WillRender = true;
    10.         }
    11.     }
    12.  
    13.     public interface IWillRenderListener {
    14.         bool WillRender { get;set;}
    15.     }
    Then from your IK component you implement IWillRenderListener and add yourself as listener, in our case server and owner should always solve IK

    Code (CSharp):
    1.      
    2.        foreach (var willRender in GetComponentsInChildren<WillRender>()) {
    3.             if (isServer || IsOwner) {
    4.                 Destroy (willRender);
    5.             } else {
    6.                 willRender.SetListener (this);
    7.             }
    8.         }
    And lastly in your IKUpdate method
    Code (CSharp):
    1.      
    2. ik.enabled = WillRender;
    3. WillRender = false; //Not very elegant
    4.  
     
    Last edited: Sep 17, 2016
  46. justtime

    justtime

    Joined:
    Oct 6, 2013
    Posts:
    351
    Hi Partel!
    I have a problem : when player attacking and weapon has collision with, for example, wall, i need make some impact on the player and reverse attack animation speed or goes to idle state(like in Chivalry). Is your asset can be useful for my purpose ?
     
  47. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,058
    Hi,
    You could try adding a LimbIK component and assigning shoulder, upper arm and forearm as Bones, then it will solve for the position of the elbow.

    Hi! Could you please send me that character setup so I could take a closer look? PM or support@root-motion.com.

    Hi,
    I suggest you dont use rotation weight at all, just rotate the hand bone to match the target in LateUpdate and set "Maintain Hand Rot" to 1. Then use the bend goals if you still need to fix something with the elbows. Rotation Weight kinda sucks, I am planning to revisit that at some point, but im not sure how to do that yet without braking some people's existing rigs using it.

    If you have any of the right arm bones in AimIK solving before FBBIK, then you must use another pass of LimbIK on top of everything to put the left hand back to where it was relative to the right hand before AimIK twisted the right arm. If you could take all right arm bones out of AimIK there would not be any need for that.

    Hi!
    Yes they will conflict because they are both heuristic solvers that iterate towards a better solution. A better solution positionally probably means a worse solution rotationally so thats where the fighting comes from.

    Could you send me that rig? There might be a solution with a bit of extra code.

    Hi!
    You could reverse attack animation speed or go to idle even without FIK, just add a script to the weapon that has an OnCollisionEnter() and if it registers a hit with a wall, use Mecanim to do something with the animation.
    FIK has a demo scene called "Motion Absorb", that will use FullBodyBipedIK to emulate a hit reaction procedurally.

    Hey, thanks for the info, will be useful!

    Cheers,
    Pärtel
     
    silentneedle likes this.
  48. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    Thanks, then I probably will remove the right arm from the aim ik.

    Another one.

    I'm currently trying to blend between those two poses:

    Rifle idle:



    Rifle aim:



    As said in my last post I'm using hand effectors to place the hands to the correct position, this works very well for the idle state, but as soon as I'm blending to the aim state it doesn't looks good anymore.

    My current plan is to add another pair of hand effectors for the aim state which I'll lerp to, but I'm not sure if this is the proper way to do. Any word on this?

    p.s. Thanks for the fast (and great) support.
     
  49. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,058
    Hi!
    You could have a list of left hand targets for all animations and weapons and stuff. Then you could check if the current or next state in Mecanim is the aim state and blend the IK target position towards the right target.

    But if you have your rifle animations, you might not want to lock the left hand at all. I mean it might be doing some reloading or whatever in that animation and if you lock it, it will be gone. You might want to use effector positionOffset instead to offset the hand relative to the right hand (so that the offset would always be aligned with the gun, not in world space).

    Code (CSharp):
    1. ik.solver.leftHandEffector.positionOffset += ik.references.rightHand.rotation * currentLeftHandOffset;
    That would enable you to use the same animations for similar weapon types, like offset the left hand closer to the right if a weapon is just a bit shorter, depends on how much perfection you are after really.

    Cheers,
    Pärtel
     
    silentneedle likes this.
  50. namdo

    namdo

    Joined:
    Feb 23, 2015
    Posts:
    185
    Hi,

    So I'm trying to write a simple script to pick up an item when a button is pressed then drop it when the same button is pressed.

    I'm able to pick up the item with

    Code (CSharp):
    1. if (Input.GetKeyDown (KeyCode.V))
    2.         {
    3.             interactionSystem.StartInteraction (FullBodyBipedEffector.RightHand, ball, interrupt);
    4.         }
    However when I try to use the stop interaction, the object doesn't fall. It has a rigidbody attached to it. I even tried using some of the examples in the demos but i can't seem to find what i'm looking for.
     
unityunity