Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[RELEASED] Simple IK

Discussion in 'Assets and Asset Store' started by KonsomeJona, Mar 4, 2014.

  1. KonsomeJona

    KonsomeJona

    Joined:
    May 25, 2013
    Posts:
    10
    We are glad to present you our second Unity asset that allows you in a few clicks to apply Inverse Kinematics on rigged models.


    It does not require Unity PRO version and is optimized for working on every platform, including desktop and mobile.

    No programming skill is required. Simple IK is very handy and only a simple drag'n drop is sufficient to make the animation work.

    Simple IK works with as many joints as you want. Some angle restrictions can also be set in order to avoid unexpected/unrealistic positions.

    Please look at our web demo available here to get an idea about what this plug-in can do. Also, read our tutorial to learn how to use Simple Inverse Kinematics on a game character.

    The price: 2$.
    The asset is available on the asset store here.

    Bonus: :cool:


    If you have any suggestion or any question, please feel free to ask!
     
    Last edited: Nov 6, 2014
    Malbers and theANMATOR2b like this.
  2. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    I presume you are using CCD? Can you add constraints so the long tail demo won't cut into each other.
     
  3. KonsomeJona

    KonsomeJona

    Joined:
    May 25, 2013
    Posts:
    10
    Hello and thank you for your reply.

    For the long tail demo, we didn't add any constraint and we disabled colliders and CCD. The purpose of the demo was just to prove that the script is working on as many joints as you want and also to show the IK behavior according to the mouse position.

    Of course, it is easily possible to add constraints to avoid parts to cut into each other. There are two ways to do this:
    • by using the angles restrictions system from our script (see finger demo, and our tutorial to see how it works).
    • by adding colliders and using CCD.
     
  4. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    tried it out on rigidbodies (ragdoll) but seems to be jolting all over the place. is it not supposed to work on rigidbodies or is there a workaround?
     
  5. KonsomeJona

    KonsomeJona

    Joined:
    May 25, 2013
    Posts:
    10
    Hello and thank you for choosing our asset.

    There shouldn't be any problem with rigidbodies. Your problem looks more about something wrong in the configuration of the IK.
    Something I forgot to mention is each joint has to be a child of the previous parent in the joint entities array.

    By example, we want to add an IK to an arm, you will have three joints : arm, forearm, hand.
    In order the IK works, arm has to be parent of the forearm, and forearm has to be parent of the hand. See the picture below:


    Of course, the order has to be the same in the joint entities array:


    Is it the case for you?
     
  6. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Hi,

    Compatible with Legacy or Mecanim?
     
    TooManySugar likes this.
  7. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    @ZouBi
    arm, forearm, hand. hm, I maybe have it the other way. will check again (cannot now).

    so this is on arm, if you want to touch with hand the target?

    what I was going to do was having a target under character capsule, and move it from the T-Pose position (or rather from the resting position) to the desired position. and see what can be done that way. but now I'm curious if you say it should work.
     
  8. KonsomeJona

    KonsomeJona

    Joined:
    May 25, 2013
    Posts:
    10
    I think you will have to add a mask to disable animation on the part of your model you want to use IK.


    If you set the IK with this array: arm, forearm, hand, the script will make the last object of the list (hand) touching the target.

    The target object must not be under one of these object: in my example, don't put target under arm, forearm or hand. It will also result with the arm jolting all over the place.
    Explanation: hand will move to touch the target, but target is under the hand (in hierarchy) so global position of the target will move with the hand. And it's becoming an infinite loop.

    This case becomes the same sitation as the image below: :D
     
  9. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    no, I didn't put target under joint. made a video where the jolting is seeable (damping 0.1-0.5, no animation), I don't know if its a physics update thing or what.
    https://www.youtube.com/watch?v=uiUjbDxG4jU

    today I added animations to ragdoll, and was suprised that it seems to kept the rigidbody physics too and joint ik working too (which would make the previous test irrelevant)

    though it seems to have an effect on other rigidbodies, but is not effected by other rigidbodies (I guess because animation overwrites physics)
     
    Last edited: Mar 6, 2014
  10. KonsomeJona

    KonsomeJona

    Joined:
    May 25, 2013
    Posts:
    10
    Hey,

    Thank you for the video but I can't tell you what's going wrong.
    Is it possible to send me your project in order to find the issue?

    It is probably a physic issue: the IK script is setting position of the joints, and by the same time, the physic engine (ragdoll physic) is also setting their position. Try to disable all physics applied on the arm.
     
    Last edited: Mar 6, 2014
  11. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    if an other skeleton (with animation) would be put under character capsule and ik targets would be joints that would be usable, aint it? that would be interesting
     
  12. KonsomeJona

    KonsomeJona

    Joined:
    May 25, 2013
    Posts:
    10
    Yes. Simple IK can work with anything. You can use Simple IK to join any kind of gameobject.
     
  13. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,286
    Great asset, works fine with most things and the price is amazing

    Only one question, i tried to make it work with the Spartan free model and the hand gets a strange dislocation, but is only in this model, any other works ok

    Probably it is a problem with the model than your script, but if you have a fix or hint of what could be done in such cases would be nice
     
  14. Takohi

    Takohi

    Joined:
    May 14, 2014
    Posts:
    58
    Hello and thank you!
    Did you try to add some rotation restrictions to the hand?
     
  15. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,286
    I did and did not seem to affect it, i will try again with different settings and get back

    This model has a separate node for the hand rotation than the one linking to the other bones i think, maybe this is the cause
     
  16. Takohi

    Takohi

    Joined:
    May 14, 2014
    Posts:
    58
    Probably... You maybe need to change the code of Simple IK in order to match it with the model. It shouldn't be hard, and code is very simple.
     
  17. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,286
    Ok, i will try that later, since it works fine in all other models and i dont even use the Spartan in my game, it was just downloaded for testing :)

    Thanks
     
  18. Sprakle

    Sprakle

    Joined:
    Jun 8, 2013
    Posts:
    31
  19. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    hi,
    made a third person controller and set up targets for ik on a sphere (I have finalIK too, but wanted a simple set-up and mecanim animations from code)
    it has to be custom set, adjusted to the animations (they are from unimations.com) but work kinda alright
    here's how it looks like
    but the collisions dont seem to be working. is it a late update thing or bug in the beta19(?)
    see demo> http://www.mediafire.com/download/kiclr5zp4vy3jxy/thirdpersonIkshooter.apk
    Unity 2014-10-12 22-17-01-83.png
    and also two-gun setup
    Unity 2014-10-13 01-33-10-81.png
     
  20. Takohi

    Takohi

    Joined:
    May 14, 2014
    Posts:
    58
    Hello and thank you for using SimpleIK!
    Concerning your collision issues, does your collider gameobjects also have a rigidbody?
     
  21. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    of course Im using SimpleIK. it's good and simple!

    I think something went wrong with the project, that the collisions stopped workin, (yes I think on the capsule is a rigidbody * but after reinstall it worked alright.
    *(this gives me the idea of if I'd use ragdoll colliders and if Id use collision w/w-out kinetic(?) rigidbody on capsule, but then the charactercontroller wuddi work?)

    what is your setup? how do you using it
    do you start with a T-pose?
    I was thinkin about using for a sword, but this kinda approach w a sphere needs axes limited (I managed to save miself from scriptin it by sheer luck)
    or
    start w hands together a them follow one cube on a sphere or some spline
    like this one
    better paths
     
  22. Takohi

    Takohi

    Joined:
    May 14, 2014
    Posts:
    58
    Simple IK is setting positions and rotations with this code:
    Code (CSharp):
    1. transform.position = {position};
    2. transform.rotation = {rotation};
    Well, in this case, colliders will not work so well. But if you are sure that a rigidbody is attached to the component, please change these lines by:
    Code (CSharp):
    1. rigidbody.MovePosition({position});
    2. rigidbody.MoveRotation({rotation});
    http://docs.unity3d.com/ScriptReference/Rigidbody.MovePosition.html

    Here is why:
    Please tell me if it worked and I will update the asset!
     
    Last edited: Oct 30, 2014
    hopeful likes this.
  23. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    Thanks for helping.
    I didn't notice that IK-ed bone follows the rotation of the target (and just checked, it follows the position, but not the rotation)

    Code (CSharp):
    1. transform.position = {position};
    2. transform.rotation = {rotation};
    should this be in the SimpleIKSolver.cs? (I don't see it there)
    or this is for the ragdoll kinematik idea? (I'm not there yet, I'm slow)

    but I have a more complex issue which I guess is because of script execution order, and get back after a couple tests with the description.

    so I have a set-up which almost works
    what I want to achieve is to the IK follow the target set by BetterPaths



    1. Controlfreak input script js, FixedUpdate (+animator.SetFloat to animatorcontroller)
    2. IK target BetterPathController script cs, Update
    3. SimpleIK script cs, LateUpdate
    4. camera cs, LateUpdate

    it looks like it works in the Scene window, but in the Game window it doesn't follow the IKtarget like it should and the IKtarget gets "left behind" when moving.
    I guess I should rewrite the ControlFreak script to cs and integrate the BetterPathsController for IKtarget into that too (since target positions work fine in it without the path)

    ...update>
    ok, strangely now works in the game window too (but still the IKtarget doesn't follow the capsule, though it is the child object of it)
     
    Last edited: Nov 1, 2014
  24. Takohi

    Takohi

    Joined:
    May 14, 2014
    Posts:
    58
    Yes,

    Line 107:
    Code (CSharp):
    1. JointEntities[link].Joint.rotation = Quaternion.AngleAxis (turnAngle, crossResult) * JointEntities[link].Joint.rotation;
    Try to replace it by:
    Code (CSharp):
    1. JointEntities[link].Joint.rigidbody.MoveRotation(Quaternion.AngleAxis (turnAngle, crossResult) * JointEntities[link].Joint.rotation);
    Please also comment the line 109:
    Code (CSharp):
    1. CheckAngleRestrictions (JointEntities[link]);
    Concerning your other issue, I am sorry, I can't help you as I don't know how works BetterPathsController.
     
  25. Takohi

    Takohi

    Joined:
    May 14, 2014
    Posts:
    58
    We released a new video demonstration of Simple IK to show you how powerful this asset is :D


    (yes, we have a lot of effort to do in marketing,,, :p)
     
  26. Barry100

    Barry100

    Joined:
    Nov 12, 2014
    Posts:
    200
    cant get it to work at all ?? I have tried other IK's scripts which are not 100% doing what I want although they do work (js versions). I have set up a mask for the avatar arms and made it so they are not influenced by the animations but still I cant get your scrip to move anything? any advice? I really would like to get this working.
     
  27. Takohi

    Takohi

    Joined:
    May 14, 2014
    Posts:
    58
  28. Kisku

    Kisku

    Joined:
    Jan 8, 2015
    Posts:
    2
    Hi, I am pretty new to Unity. (v4.6) I am trying to create a 2D climbing game. The user can drag the player character left hand, right hand, left foot and right foot to specific points.

    The Character hierarchy looks like:
    - lower torso
    - upper torso
    - right shoulder
    - right arm
    - right hand
    - right upper leg
    - right lower leg
    - right foot

    I am using Simple IKSolver script for the arms/legs movement My question is, when I drag, for instance, left hand, how can I anchor the other hand and feet to limit the movement of the character?



    Thanks in advance.
     

    Attached Files:

  29. Takohi

    Takohi

    Joined:
    May 14, 2014
    Posts:
    58
    Hello and thank you for using our asset!
    I am sorry, I don't understand so much what you are really trying to do. Could you explain me more?
     
  30. Kisku

    Kisku

    Joined:
    Jan 8, 2015
    Posts:
    2
    Hi, basically is a 2D climbing game.
    The character have 4 grip points (left and right hand, left and right foot) As you can see on the image above.
    The player controls the character by dragging either hands or feet to specific points on the screen.
    If a hand or foot collides with these specific points it automatically grab the wall and freezes it position.

    The problem is that when I drag the hand and start dragging it, the rest of the body (except the arm) does not move with it.
    Is there any way to make that when pulling the hand, the rest of the body is affected by the same force?

    Thanks again.
     
  31. Takohi

    Takohi

    Joined:
    May 14, 2014
    Posts:
    58
    You should take a look at the Ragdoll feature of Unity, it is exactly what you are looking for!
    Ragdoll wizard will allow you to easily add joints between the bones of your character. Then if you move one bone, everything will just follow as you expect.
     
    Kisku likes this.
  32. sheffieldlad

    sheffieldlad

    Joined:
    Oct 9, 2013
    Posts:
    154
    Hi @Takohi
    I bought this today, is working really well for me.
    One quick question, What does the damping value do?
    I was hoping it would make the joints reach for the target slowly but it doesn't seem to do anything.
    Is there a way to get the specified joints to reach the target slower?
    I've changed line 107 as you specified above because I'm using a ragdoll with rigidbodies attached.

    Many thanks.
     
  33. sheffieldlad

    sheffieldlad

    Joined:
    Oct 9, 2013
    Posts:
    154
    BTW, If anyone needs to mix limbg with rigid bodies and limbs which don't have rigid bodies attached the following worked for me...

    comment out lines 107 and 109 and replace with the following..

    Code (CSharp):
    1. if(JointEntities[link].Joint.rigidbody !=null)
    2.                 {
    3.                 JointEntities[link].Joint.rigidbody.MoveRotation(Quaternion.AngleAxis (turnAngle, crossResult) * JointEntities[link].Joint.rotation);
    4.                 }
    5.                 else
    6.                 {
    7.                 JointEntities[link].Joint.rotation = Quaternion.AngleAxis (turnAngle, crossResult) * JointEntities[link].Joint.rotation;
    8.                 CheckAngleRestrictions (JointEntities[link]);
    9.                 }
    :)
     
  34. Takohi

    Takohi

    Joined:
    May 14, 2014
    Posts:
    58
    Indeed, damping should make the joints reach the target slower and it works. Did you try different values?
    Could you make it work since?

    Thank you for your suggestion! :)
     
    sheffieldlad likes this.
  35. sheffieldlad

    sheffieldlad

    Joined:
    Oct 9, 2013
    Posts:
    154
    hi @Takohi I haven't had chance to try it since. I have tried values ranging from 0.05 all the way up to 50 and I didn't notice a change in the speed.
    Is a smaller value supposed to be more or less damping?
     
  36. Takohi

    Takohi

    Joined:
    May 14, 2014
    Posts:
    58
    Look at this part of the code:
    Code (CSharp):
    1. // APPLY DAMPING
    2.                 if (IsDamping) {
    3.                     if (turnAngle > DampingMax)
    4.                         turnAngle = DampingMax;
    5.                 }
    It is how it works. Does isDamping checkbox is activated in the inspector?
     
  37. sheffieldlad

    sheffieldlad

    Joined:
    Oct 9, 2013
    Posts:
    154
    yes, the damping check box is checked.
    To be honest, it could be my use case. The parts I have IK'd don't have to move very far so it may be difficult to spot any damping.

    I will try to upload a video later on today.
     
  38. davidk_43

    davidk_43

    Joined:
    Feb 19, 2015
    Posts:
    10
    Hi Takohi, this is a really handy little script. I have an issue which maybe easy to solve or you be able to point me in the right direction. I have a reasonably simple 3 joint arm that i'm looking to make follow a target object that's being tweened. I'm currently using LeanTween.

    It sort of works but the tweened object moves smoothly and the joints following it are quite choppy, almost like a dropped frame when the desired rate can't be kept up with. Possibly an Update issue? I don't think its a performance issue as its very simple and if manually dragged around it renders fine. Or perhaps I should be using a native Lerp rather than LeanTween?

    thanks for any thoughts on this
     
  39. davidk_43

    davidk_43

    Joined:
    Feb 19, 2015
    Posts:
    10
    I may have answered my own question but I'd welcome any further input if possible. If I change the IK_POST_THRESH float to zero it runs smoothly. Presumably this is a performance thing. My use is very simple so I'll probably get away with it but no doubt playback will tell me otherwise when it doesn't!
     
  40. HWQLearner

    HWQLearner

    Joined:
    Jan 24, 2014
    Posts:
    7
    Hi, I am new in IK. May I know is it possible that I modify value of rotation or position of specific joint which using slider instead of using mouse input?
     
  41. Takohi

    Takohi

    Joined:
    May 14, 2014
    Posts:
    58
    Hello,

    I don't really understand what are you trying to do. But if you want to manually set the rotation or position of a specific joint, this is not IK anymore.
     
  42. HWQLearner

    HWQLearner

    Joined:
    Jan 24, 2014
    Posts:
    7
    May I know is it possible that I using IK to edit animation?
     
  43. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    397
    I'm having trouble with the joints snapping between angles and not having the joint match the target position. I'm trying to get my left hand to follow the right hand which has a gun in it. I've even turned off all the angle restrictions and it still snaps between positions. Anything I can do to remove this snapping?
     
  44. Steviebops

    Steviebops

    Joined:
    Apr 9, 2013
    Posts:
    132
    I'm also having trouble with damping, did anyone
    Did you ever fix the damping issue?
    It's not working for me either, and the sudden snap when IK activates is quite jarring
     
  45. Takohi

    Takohi

    Joined:
    May 14, 2014
    Posts:
    58
    Are other physic mecanisms applied on your joints (rigidbody, gravity, or other script)?
     
  46. Steviebops

    Steviebops

    Joined:
    Apr 9, 2013
    Posts:
    132
    Yes, the character is affected by gravity.
     
  47. BraveWill

    BraveWill

    Joined:
    Feb 26, 2016
    Posts:
    3
    Hey Takohi! Firstly, I just want to say that thank you for your script. It's really saved me a lot of programming headaches when it comes to various applications.

    I'm currently trying to make a robot arm (or crane), where the joints are cylinders that only allow rotation about one axis. Similar to a hinge joint. My issue is, whenever I use the angle restriction range, it automatically orients the cylinder in the incorrect position.

    Here are some pictures to illustrate the issue:

    Picture1.png The "empties" are to prevent deformation upon rotation. The servos are the joints. The white "servo" has be restricted like so, and is working as expected.

    Picture2.png
    I'm trying to get the bottom most, grey cylinder to rotate like so.

    Picture4.png
    ... and not like this. So when I restrict it, I get this issue.

    Picture3.png
    It ends up looking like this. To the right are the settings I have. The second servo's restrictions are slightly cut off, but the Z-Axis has been restricted to 0,0.

    So is this an issue that I can't get around? Thank you for the reply!
     
  48. Takohi

    Takohi

    Joined:
    May 14, 2014
    Posts:
    58
    For every cylinder, you will need to create an empty object. Then rotate the cylinder to match the right rotating position, and use the empty object parent as joint for simple IK.

    So you will have:
    • Servo
      • Cylinder (rotated to the right position)
      • Empty
        • Servo
          • Cylinder
          • Empty
     
    BraveWill likes this.
  49. BraveWill

    BraveWill

    Joined:
    Feb 26, 2016
    Posts:
    3
    Thank you!
     
  50. Dracin

    Dracin

    Joined:
    Feb 25, 2014
    Posts:
    10
    Hey,

    I just purchased your asset an I'm having a couple of problems.

    The first is snapping of position . When I move the target the bones that follow seem to snap to the target instead of moving smoothly.

    The second is that It seems like the bone following the target is placed at an offset to the targets position.

    Any help would be greatly appreciated. Cheers