Search Unity

  1. Unity 2019.2 is now released.
    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. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,105
    Yes. I believe I didn't see it right after the update but a little later while working on the setup. One thing I know I did was copy the stretch curves from the Pilot example to my character. Before, that curve was "empty", so it may be related to that. In fact, while working on another character, assigning the Pilot example curve made it significantly worse compared to not having a curve assigned at all (the state directly after the 1.9 update).

    So, just after the update, the effect is there, but it's easy to miss. With the curves assigned, it's pretty severe. That's with the curve from the Pilot. When I move the curve 0.1 "right", so that the first keyframe is on 1.0 instead of 0.9, and move the second keyframe (which is now at 1.1) down to 0.01 (instead of 0.05), I get better results. The knee still gets bent a little bit but with my offsets, it now looks good enough.

    Sure, I'll do that. It's not trivial because I still have some dependencies to my main project in my code that sets this up, and it's a MorphId-character which has its own dependencies scattered across the project. But one of my current tasks is putting my avatar system into a separate package, anyways, so that fits in well.
     
  2. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    879
    Cool! Thanks for the info.
     
  3. Filhanteraren

    Filhanteraren

    Joined:
    May 14, 2014
    Posts:
    47
    Hi.

    I have played around a little with the new Animation Rigging Tools that Unity is currently working on and while it still feels a bit unfinished it has some interesting concepts.

    The ability to animate the different IK effectors and animate weight of the different rigs to make new procedural animation is really nice. Seems like a nice and straight forward way of doing different rigs for weapons and so on that I always struggled a little with using Final IK.

    I saw that the latest update included a script for seeing the IK result in offline editor mode, with that I guess it would be possible to easier animate the IK effectors.

    So I wonder if there is any good way or best practice to do this in Final IK or if there is similar way of doing this without to much code work?
     
  4. NikkiC5

    NikkiC5

    Joined:
    Jun 11, 2016
    Posts:
    9
    Hi,

    I've been struggling with VRIK with an issue where the pelvis of the avatar rotates when "IK Position Weight" is set to anything other than 0, even when the solver targets are null. It seems to be the identical issue as experienced by the developer in the link below:
    http://root-motion.com/qa/index.php?qa=3857&qa_1=problem-with-hips

    However, I updated from 1.8 to 1.9 and the issue has not been resolved. What is causing this rotation and how can I resolve it, please?

    Thanks
     
  5. andrew210

    andrew210

    Joined:
    Apr 23, 2014
    Posts:
    153
    Hello! I seem to have stumbled over on an issue with the quadruped grounder causing some issues which repeatedly lifts the quadruped up into the air, then drops it again, then repeats this.
    , here's a video that explains it a little bit better than I could. There is a small drop down between the two surfaces but does not get close to the min / max body rotation values. I can also rotate the body of the quadruped around and note that it doesn't have the same issue when facing the other direction. Any advice as to what's gone wrong in the way I've set this up would be greatly appreciated! Thank you!
     
  6. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,957
    Hey,
    Basically all that is possible with FIK, you can add IK components on top of each other and each component also has a weight parameter for smooth blending. Yes, you can make FIK update in editor mode by adding the EditorIK component, but not sure how that could be used to make the workflow easier at the moment. I'm currently working on some pretty cool editor stuff that might though. :)

    Hey,
    I thought that issue was solved, but I guess not. Usually it happens when the spine bone is too close to the pelvis bone. Some rigs even have the spine almost at the same position, so when the solver applies the mapping, the pelvis up axis is turned towards the spine bone and when it is too close, it results in a lot of rotation.
    If your character has more spine bones, you could try assigning another bone for Spine in VRIK's References, try using the child of the old spine bone.

    Hey,
    That is some weird stuff I have not seen yet. Any chance you could package me that horse with the Grounder setup you have and send it over? Otherwise I can only guess.

    Cheers,
    Pärtel
     
    khos likes this.
  7. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    879
    Looks interesting, just what I am after, is this possible now, or must we wait for a future update? Seems like editing / mixing current animations with IK (animations), cool!
     
  8. ftejada

    ftejada

    Joined:
    Jul 1, 2015
    Posts:
    533
    Hi @Partel-Lang !!
    I'm having a problem and I don't know what I'm doing wrong or what the problem is.

    I am using the latest version of Final IK and I have configured my character as you have it in your example scene "Interaction Wall".

    The problem is that the "Hand Poser" scripts are not receiving any tranform in the "Pose Root" parameter. For this, the hands do not have any rotation to adapt to the pose that corresponds to them.

    I leave small video for you to see the configuration and problem:



    Why am I having this problem?

    What I want to achieve using TouchWall script is that when the character approaches a door (with Hinge Joint), it seems that he opens it with his hands.
    I've been doing some tests with the character of the "InteractionWall" scene and when you're walking with the character the effect I'm looking for happens perfectly. But when I run, this technique does not work well, because the character goes too fast and does not have time to detect the point of collision where he must knock on the door with his hands. Any idea how to manage this problem? I leave another video for you to see what I mean:



    Regards
     
  9. andrew210

    andrew210

    Joined:
    Apr 23, 2014
    Posts:
    153

    Thanks so much for getting back to me. I think what I've decided was going on was since, my horse has two capsule colliders at the front and back of it and are scaled up and down depending on on the animation state. As it's got the two capsule colliders either side instead of one sphere collider encompassing the whole body (like the wolf in the quadruped demo), the capsule colliders take care of the rotation of the body.

    In short, stopping the quadruped grounder from rotating the body seems to have sorted the issue!
     
  10. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,957
    Hey,
    It is still a WIP, it will take some time, not easy to deal with the Playable API. But yeah, there will be Timeline support and what you saw in the video could be used in real-time, but also baked to a clip with the Baker.

    Hey,
    The problem is that the target hierarchy must match exactly with the character's hand hierarchy. You might have used another character's hand bone to pose the InteractionTarget.

    Best,
    Pärtel
     
    khos likes this.
  11. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    877
    Oh man, this is super exciting. That is 100% exactly what I need right now. I came in here to see if there was any sort of Timeline integration as being able to use FBIK and Look-At would be perfect for my current cinematic I am working on. Can't wait for this to come out! Can I donate to help speed up development? :p
     
    khos likes this.
  12. BernieRoehl

    BernieRoehl

    Joined:
    Jun 24, 2010
    Posts:
    67
    Hi Pärtel

    I'm trying to figure out the correct way to use VRIKAnimatedLocomotion. What I would like to do is let VRIK handle small movements, like the user taking a step or two in some direction or crouching down, and have VRIKAnimatedLocomotion handle walking over longer distances.

    I'm thinking that for VRIKAnimatedLocomotion to work, locomotion.weight should be zero. However, for VRIK to handle the stepping and crouching, locomotion.weight should be one. I'm wondering if I need to dig into VRIKAnimatedLocomotion and have it change the locomotion.weight value?

    Is that the right approach, or is there a better way? Or am I missing something obvious altogether?

    As always, thanks for any help.
     
  13. HoneyTribe

    HoneyTribe

    Joined:
    Mar 7, 2013
    Posts:
    22
    Hey Partel, I'm trying Finak IK with the character controller in one of the demos you made, the "Grounder" demo.

    The CameraController script has a field in the inspector for Blocking. Is this a feature to avoid clipping objects that are between the player character and the camera? It should move the camera so the player can always be seen without needing to "see through" objects? Or have I misunderstood what Blocking does?

    Thanks,
    Shaz
     
  14. ftejada

    ftejada

    Joined:
    Jul 1, 2015
    Posts:
    533
    Hi @Partel-Land !
    In the following video, I show the hierarchy of the right hand and the hierarchy of the target. As you will see they have the same hierarchy. And although I don't show the target hierarchy of the left hand, it also has the same hierarchy as the bones of the character's left hand.
    Any idea what causes the problem?


    On the other hand you have not answered me to the second part of the last message that I put you up here. Any suggestions or ideas on how to get it would be greatly appreciated.

    Greetings
     
  15. gliealonso

    gliealonso

    Joined:
    Oct 21, 2018
    Posts:
    10
    Hi Partel,

    I am having issues setting up a VRIK, it must be a very silly mistake, however I have spent 2 days trying to fix this already.

    What happens, is that the hands aren't at the correct position, and if I try to move the hand bone to match the controller, the arms starts going in a totally wrong direction, as you can see from the images attached. (The head bone is working though).

    In one image you can see that the bones are zeroed out just like the tutorial, and I also attached an image showing how VRIK is setup.

    Many thanks!
    Gabriel.
     

    Attached Files:

  16. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,957
    Hey,
    I'm already working as fast as I can so I don't think a donation would help.. there are many issues to be solved, still working on FBBIK part, haven't even got to LookAt yet, but I'll take it on next. If you'd like to try and test the current WIP implementation, please PM me.

    Hey,
    If that's what you need to do, I'd suggest you blend ik.solver.locomotion.weight to 0 when the player uses the thumbstick to move, switch to VRIKAnimatedLocomotion then. When the thumbstick is released call ik.solver.Reset() and blend locomotion.weight back in.
    I'd probably go for all animated solution though, the transition from procedural to animated and back might feel weird.

    Hey,
    Yes, that is exactly what blocking does, just assign layers you'd like to block the camera and make sure it does not include the character's own capsule or ragdoll collider layers.

    Oh, sorry, I just noticed in your original video, you had "Target Tag" set to "Player" in the InteractionSystem component. With that, your InteractionTarget objects need to have the "Player" tag too or they'll be ignored. Target Tag is used for when you have multiple characters with different hand hierarchies so IS would know which InteractionTarget to use for each character.

    Sorry to have missed your second question. I think you'll just need to increase InteractionSystem.speed while you are running.

    Hey, I noticed you already have PuppetMaster running on that rig? Could you try if the problem goes away if you set PuppetMaster's "Mapping Weight" to 0. If it does, it's a PM problem, if not, it's an IK problem.
    If it's PM, try if disabling "Angular Limits" and/or "Internal Collisions" makes it go away. If so, you'll have to loosen either the joint limits or collider sizes so they would allow for a bigger range of motion.

    Best,
    Pärtel
     
  17. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    879
    Hi, I would be interested Pärtel, hopefully it would be ok to do the same for me?
     
  18. ftejada

    ftejada

    Joined:
    Jul 1, 2015
    Posts:
    533
    Hi @Partel-Lang !!!

    Thanks for the help. The problem was the Tag.

    Regarding the opening of doors when the character runs, I had already tried it before you mentioned it in your previous message, but just by increasing the value of InteractionSystem.speed, it doesn't look good.

    The problem seems to go at a higher speed the door is detected too late for the speed that the player carries. How could it make the detection of that door and the reaction to start bringing the hands to the target faster? And I don't mean the speed of transformation of the hands to the target ...
    Maybe changing the value of some parameters in TouchWalls? Although I have already given it different values and not getting what I want

    On the other hand, limitations can be applied to the rotations of the bones so that they do not have unnatural postures, (such as crossing the torso with the arm) I leave images:
    RotationLimitsFinalIK2.jpg RotationLimitsFinalIK.jpg
    Regards
     
  19. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,957
    Hey, of course, I'll reply your PM in a minute..

    Hey,
    OK I see. I added distanceMlp for TouchWalls.cs, so you could increase that value while you are running. Here's the script.

    About preventing that arm from going into the chest, you could do that by adding RotationLimit components to the upper arms. Rotation limits can not be used by the solver in the solving process, but they could be applied on top of FBBIK to keep the arms out of the chest. To do that, you'll need to apply a script like this:

    Code (CSharp):
    1. public FullBodyBipedIK ik;
    2.     public RotationLimit[] limits;
    3.  
    4.     private void Start()
    5.     {
    6.         foreach (RotationLimit limit in limits)
    7.         {
    8.             limit.enabled = false;
    9.         }
    10.  
    11.         ik.solver.OnPostUpdate += AfterFBBIK;
    12.     }
    13.  
    14.     void AfterFBBIK()
    15.     {
    16.         foreach (RotationLimit limit in limits)
    17.         {
    18.             limit.Apply();
    19.         }
    20.     }
    Best,
    Pärtel
     
  20. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,489
    I really wish this asset to be on sales soon. Haha.. spent too much $ on this month already. Maybe I should go with BioIK or something cheaper.. T.T
     
  21. Zara_

    Zara_

    Joined:
    May 4, 2018
    Posts:
    1
    Hi Pärtel!
    I want to use the Limb IK component for "weapons slots", where the target is placed on the weapon. I have been using Limb IK as an offset, problem is that the IK overrides the animation. Is there a way to make Limb IK addative or in some other way keep the animation?
    I tried to use the "weapon hold offset" but I can't set a target and have to manually put in the numbers. I would want to be able to set the offset to a point so that it can be used for multiple characters without having to change the numbers.

    Sorry if this has already been answerd!
     
  22. BernieRoehl

    BernieRoehl

    Joined:
    Jun 24, 2010
    Posts:
    67
    We're not using thumbsticks, we're free-roaming in a 10m x 10m space. Head and both hands are tracked.

    I've tried the all-animated solution (by setting locomotion.weight to zero) and for some reason it doesn't work well. There is no smooth walking motion (even though I can see in the animator window that the transition from Idle to Walking is working correctly), and the feet lag behind the head movement quite a bit. The avatar appears to stagger as he walks.

    I can get smooth walking by setting the IK position weight to zero, but of course that means I can't crouch or sidestep or anything.

    Is there some setting that I'm missing? Here are my VRIK settings...

    upload_2019-10-16_14-13-55.png

    ... and here are my VRIKAnimatedLocomotion settings:

    upload_2019-10-16_14-14-49.png
     
  23. ftejada

    ftejada

    Joined:
    Jul 1, 2015
    Posts:
    533
    Hi @Partel-Lang !!! Thank for reply

    This script for the limits of rotation would go in the Character I guess, right?
    And in the array of Limits that I must add all the bones of the arm (except the hand) or just the bone "Shoulder" and the script is already responsible for taking the transform children of the hierarchy of the arm?
    I see in the example code that you put that in the Start function it deactivates the RotationLimitsAngle scripts ... Does this mean that the limits we have to set them only before giving the Play?

    Another question the script that I must attach to each arm bone is "RotationLimitsAngle"?

    Regarding the solution for when the character runs, the new parameter you have set (distanceMlp) does not solve the problem. Despite using quite high values in that parameter (1 ~ 5 for example), the character does not usually react to the door until it is too late and not very well.
    I think there is no simple solution to fix this problem and we should touch more code from the TouchWall script.

    I don't understand how it works but it uses "sphereCast from". But in which direction does that sphereCast come out? forward character?
    I get the feeling that the problem may come from there since sometimes I get the feeling that the system does not interpret well when you have to send your hand to the wall / door.

    Any explanation or idea will be welcome.

    Regards
     
  24. Kagyu

    Kagyu

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

    I do not see rotation weight for the Body Effector of Full Body Biped IK on the inspector.
    I need to rotate my character's hip bone procedurally with FBBIK. I wrote something like below in a script but it seemed not working.
            fbbik.solver.bodyEffector.rotationWeight = 1.0f;

    How do I make it working? or is there any work around?
     
  25. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,957
    Hey,
    Sorry, not up to me, but usually there is a big sale on black friday :)

    Hey,
    You can make LimbIK work additively on top of animation like this:
    Code (CSharp):
    1. void LateUpdate() {
    2. ik.solver.IKPosition = ik.solver.bone3.transform.position + offset;
    3. }
    Now, if you are working with weapons slots, that offset will have to be applied in the rotation space of the weapon so if the weapon rotates, the offset will rotate the same way:

    Code (CSharp):
    1. void LateUpdate() {
    2. ik.solver.IKPosition = ik.solver.bone3.transform.position + weapon.TransformVector(positionOffset);
    3. }
    So since the offset is applied in weapon space, it should work with multiple characters too, independent of their bone orentations.

    Hey,
    It depends mostly on the animations that you are using, which animation package did you use? Have you tried tweaking the values in VRIKAnimatedLocomotion? Increasing the key values in "Animator Speed By Distance" and "Step Length By Distance" would make it take longer steps more quickly to catch up with the HMD. Increasing "Velocity Add" might help too. I've had the best results with Kubold's animsets so far, that's what we used in Dead and Buried 2.

    Hey,
    The rotation limit script could be on any gameobject, as long as you add the limits to the array, it will work.
    You can use any of the 4 rotation limit components - RotationLimitAngle, RotationLimitHinge, RotationLimitPolygonal and RotationLimitSpline. Angle is just an angular limit, the last 2 allow you to set up the limit range in more detail.

    About the walls, the sphere cast is done from "Spherecast From" towards the "Interaction Object". If a hit is found, it will start the interaction with the interaction object to move the hand to it. I double checked the code and all interpolation speeds are multiplied by InteractionSystem.speed, so increasing that should really make it faster, not sure to improve it really.

    Hey,
    Please check out the "Offset Effector" demo, it shows you how the thigh and shoulder effectors can be used to make rotation targets for the pelvis and spine.

    Best,
    Pärtel
     
    ftejada likes this.
  26. Kagyu

    Kagyu

    Joined:
    Mar 5, 2016
    Posts:
    55
    Sweet. The Offset Effector is more than perfect!
    Thank you.
     
  27. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,489
    I have lookat IK setup but my head is not looking at the target. Instead, head's side is looking at the target as if the head is rotated 90 degrees.. (ear is looking at the target)

    upload_2019-10-26_18-9-36.png
     
  28. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,489
    Also, I was wondering if I use AimIK, what would be the best way to trigger a gun shot recoil animation while I am aiming? If the recoil animation is something that can change the angle of the weapon, keeping aiming does not work because animation does not override aiming of guns. So my current idea is to blend weight to 0 and then back to 1 again, but this is fiddly and blending between animation and weight value sometimes seems to interfere with each other and cause hiccups. Any advise?
     
  29. Kagyu

    Kagyu

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

    I have a strange issue regarding IKExcutionOrder.
    I add FBBIK and LookAtIK to my character by script after loading the model to the scene.
    I want LookAtIK works after FBBIK so I add IKExcutionOrder component as well.

    Then I try to pass those two IKs to IKExcutionOrder.ikComponents, I receive null reference exception error.
    My script is something like this.
    Code (CSharp):
    1.  
    2. FullBodyBipedIK fbbik;
    3. LookAtIK lookAtIK;
    4. IKExecutionOrder ikExecutionOrder;
    5. bool ikReady = false;
    6.  
    7.   // Start is called before the first frame update
    8.     void Awake()
    9.     {
    10.         SetUpFBBIK();                     //Add and set up FullBodyBipedIK in this method
    11.         SetUpLookAtIK();                 //Add and set up LookAtIK in this method
    12.  
    13.         ikExecutionOrder = gameObject.AddComponent<IKExecutionOrder>();
    14.         ikExecutionOrder.animator = gameObject.GetComponent<Animator>();
    15.         ikExecutionOrder.enabled = false;
    16.     }
    17.  
    18.     // Update is called once per frame
    19.     void Update()
    20.     {
    21.         if (ikReady == false)
    22.         {
    23.             if (fbbik != null && lookAtIK != null && ikExecutionOrder != null)
    24.             {
    25.                 Debug.Log("IK EO " + ikExecutionOrder);
    26.                 Debug.Log("FBBIK " + fbbik);
    27.                 Debug.Log("LookatIK " + lookAtIK);
    28.                 ikExecutionOrder.IKComponents.Add(fbbik);     // The log indicate this line cause the null reference exception
    29.                 ikExecutionOrder.IKComponents.Add(lookAtIK);
    30.                 ikExecutionOrder.enabled = true;
    31.                 ikReady = true;
    32.             }
    33.         }
    34.     }
    35.  
    (To feed FBBIK and LookAtIK to IKExcutionOrder.ikComponents, I have modified ikComponents from Array to List)
    Do ou have any idea what causes this issue? Or is there any good work around?

    Just FYI, everything start working well after feeding two IKs to IKExecutionOrder.Components manually while playing the scene in the Editor.

    Log.png Thanks! Log.png

    EDIT
    Code (CSharp):
    1.     private void LateUpdate()
    2.     {
    3.         fbbik.solver.Update();
    4.         lookAtIK.solver.Update();
    5.     }

    Is this the better workaround, maybe?


    .
     
    Last edited: Oct 27, 2019
  30. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,957
    Hey,
    Make sure that the gameobject that LookAtIK is attached to is rotated so that the character is facing it's positive Z axis at Start. LookAtIK samples the pose at Start to find out which axis of the head is pointing forward so that's why it matters.

    Hey,
    There is a way to make AimIK work in "additive mode". Please check out the "Aim Controller" demo. AimController is a helper tool for AimIK that takes care of all the smooth target switching, interpolation, weight blending and other stuff like that. You can enable the additive mode by checking the "Use Animated Aim Direction" box in AimController. If your aiming animation is not aiming exactly forward, you'll have to tweak the value of "Animated Aim Direction" to regain aiming accuracy.

    Hey,
    Not sure about the null ref, what do you have in ActorIKManager.cs line 71 exactly?
    But yeah, I prefer to use ik.solver.Update() myself too. It is completely fine unless your Animator is in AnimatePhysics update mode. Note that if you need the "Fix Transforms" to work, you'll have to call ik.solver.FixTransforms(); in Update() too.

    Cheers,
    Pärtel
     
  31. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,489
    Maybe my problem is that I am doing this in runtime and my character is already in some idle pose when setting up IK.
    Humm

    OR...

    My head bone looks like its local positive Y axis is facing forward... so positive Z axis is looking at the look target.. Is there way to change lookik's forward axis just like aimik?
     
    Last edited: Oct 28, 2019
  32. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,957
    Yeah, you can do it like this:
    Code (CSharp):
    1. ik.solver.head.axis = headForwardAxis;
    2.         foreach (IKSolverLookAt.LookAtBone spineBone in ik.solver.spine)
    3.         {
    4.             spineBone.axis = spineForwardAxis;
    5.         }
    6.         foreach (IKSolverLookAt.LookAtBone eyeBone in ik.solver.eyes)
    7.         {
    8.             eyeBone.axis = eyeForwardAxis;
    9.         }
    but that code needs to be called after LookAtIK has already initiated, otherwise it will be overwritten. You can check ik.solver.initiated for that.
     
    castor76 likes this.
  33. Kagyu

    Kagyu

    Joined:
    Mar 5, 2016
    Posts:
    55
    Thank you so much for advises.
    I think I am going to go with ik.solver.Update then.

    Code (CSharp):
    1. ikExecutionOrder.IKComponents.Add(fbbik);
    This was the line I had in the line 71 of ActorIKManager.cs. I totally could not understand why I got the error...
     
  34. razzraziel

    razzraziel

    Joined:
    Sep 13, 2018
    Posts:
    135
    Hi @Partel-Lang

    I have both Final IK & Puppet Master, and those are two of my favorite tools. Great works, really appreciated.

    I started to play with Final IK for interactions and dived into codes. As far as i see, we need to use triggers for interaction system to register them. But here is my situation.

    I have a lot of moving colliders already (moving big vehicle) and a lot of interactable objects for Final IK. But i dont want to use more colliders for triggers (Some of them auto interactions like your interaction walls demo). Also i really liked your trigger approach (angles, effectors, position etc). Here is what i'm trying to do.

    I'll integrate similar features for player (for example left hand effector is for only 50 degree angles of player front). Here is example view on top.

    So instead of trigger based restrictions, i'll just have one on player for all effectors and interaction objects. And i need to use something like spherecast for this area to see all interaction objects just in this area. Without extra triggers of course.

    If i spherecast, it will search all the interaction objects in scene, right? Which way would be faster (100+ interactable objects on moving vehicle). Is there any easier way to detect nearby objects built in for Final IK? For interaction targets? (not triggers because some interaction objects have 10+ interaction targets so i need to find which ones are in this sphere) I couldnt see in interaction system codes, they are just designed for triggers and their collider triggers. If there is no built in function like that, do you think it would be good to use Bounds.Intersects with a player sphere instead of searching all the lists of interaction targets for their position distance?
     
  35. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    879
    This is an interesting post to me, I am looking/working on something similar (probably for a completely different game though :) ), a system that can detect when objects come close and e.g. a hand is stuck out to block the object, something like that, is that what you want to achieve?
     
  36. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    996
    @Partel-Lang I started working with Final IK a few weeks ago, and I just wanted to post here and say what an excellent tool you have created! I am primarily a programmer, not an animation specialist, but the project has an NPC with a requirement for interacting with scene props under script control while simultaneously using traditional animation controls for locomotion. I decided to try Final IK with some custom C# scripts for what amounts to procedural animation, rather than asking the animator to cook up a pretty complex set of blend trees and animation layers.

    The project uses the full-body humanoid IK rig in Final IK to control the arms, head, and body posture, and I modulate the influence of the effectors by dynamically altering their weights (and some other parameters) with C# code and some simple Lerping with configurable properties to control the in/out blends. I also dynamically assign effector targets from scripts. It's all working exactly as I had hoped, and now I'm going to use Final IK to replace some of my homegrown head "look at" logic on a nonhuman character, because I know I'll get a more realistic result with minimal work.

    Well done! I'll be out on the Asset Store soon to give Final IK the five-star rating it deserves.
     
    Partel-Lang and hopeful like this.
  37. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    879
    Very cool ! Would you mind posting a small snppit of the code, I would like to understand how you smoothly adjust the weight, I am trying something like that but mine is far to quick, not smooth... I can understand if you don't want to share.
     
  38. razzraziel

    razzraziel

    Joined:
    Sep 13, 2018
    Posts:
    135
    Yeah kinda. I just want to place all interaction transforms(for example hand transforms on all over the place) and player to detect them with specified restrictions(interaction trigger styled) for each target. Not their triggers. I already did it but i dont want to search all interaction targets in scene with distance check for each one of them.
     
  39. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    996
    Sure, I'll see if I can extract the relevant pieces concisely. The trick will be making sure I get enough context to make it useful. It may take me a bit of time to sort that aspect; ping me by PM if I don't get back to you in a reasonable amount of time. :)
     
  40. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    996
    Finding the code was easier than I thought. Excerpts follow; I'll assume you know the normal Unity coding stuff to declare the variables etc., so I won't put those lines here. The "grasping target" here is a pair of empty GOs under a single parent, one indicating where the NPC's left hand should go and the other the right. The grasping target assembly follows the movement of the object the NPC is supposed to visually appear to grasp when the IK is active.

    Code (CSharp):
    1.         // Initializes the references to the grasping targets mount and its two child points
    2.         private void SetTargetOffsets() {
    3.              
    4. // Snipped out the non-relevant part where the code figures out where the left and right
    5. // grasping targets are in the grasped object's local hierarchy
    6.  
    7.                 DebugUtility.Log("Target assembly objectives are (left) "+graspingTargetLeft.name+", (right) "+graspingTargetRight.name);
    8.                 // Assign the IK effector targets but set their weight to zero. At start,
    9.                 // the target mount assembly is local to the NPC. It is set to follow the
    10.                 // active target during each target selection.
    11.                 handEffectorL.target = graspingTargetLeft;
    12.                 handEffectorR.target = graspingTargetRight;
    13.                 handEffectorL.positionWeight = 0f;
    14.                 handEffectorR.positionWeight = 0f;
    15.                 DebugUtility.Log("NPC "+name+" has initialized its grasping target assembly.");
    16.             }
    17.         }
    18.      
    19.         void Start()
    20.         {
    21.             // Obtain the needed references from Final IK
    22.             ik = GetComponentInChildren<FullBodyBipedIK>();
    23.             if (ik == null) {
    24.                 Debug.LogError("A Final IK Full Body Biped component must be attached to same GameObject as the Animator.");
    25.             } else {
    26.                 handEffectorL = ik.solver.leftHandEffector;
    27.                 handEffectorR = ik.solver.rightHandEffector;
    28.             }
    29.         }
    30.  
    31. // Snipped out some additional non-relevant logic here
    32.  
    33. // The following is an excerpt of the method that updates the primitive FSM for the attack
    34. // behavior. The hands reach to grasp the enemy (at the left and right target points)
    35. // during the REACH phase, follow the targets during the HOLD phase, and return
    36. // to whatever position the normal character animations decree during the RETRACT
    37. // phase. The stateTimeCompletion variable (a float) is updated elsewhere and
    38. // basically does an "eased Lerp" from 0 at the beginning of the state to 1 at its end, when
    39. // it's time to enter the next state. This happens pretty fast in our game, so we
    40. // didn't need a lot of precision to control the movement curve here.
    41.  
    42. private voice UpdateStateMachine() {
    43.        // Housekeeping code snipped
    44.      switch (currentAttackState) {
    45.        // Code for all other states removed here
    46.             case AttackStates.REACH:
    47.             case AttackStates.HOLD: {
    48.                 positionWeight = stateTimeCompletion;        // The generic lerp produces exactly the value we need
    49.                 if (activeTarget == null) {
    50.                     SetNextState(AttackStates.RETRACT);
    51.                 } else {
    52.                     if (stateTimeEnded && currentAttackState == AttackStates.REACH) {
    53.                         SetNextState(AttackStates.HOLD);
    54.                     }
    55.                 }
    56.                 break;
    57.             }
    58.             case AttackStates.RETRACT: {
    59.                 positionWeight = 1.0f - stateTimeCompletion;    // Simply lerping from 1 to 0 for the retract
    60.                 if (activeTarget != null) {
    61.                     SetNextState(AttackStates.REACH);
    62.                 } else {
    63.                     if (stateTimeEnded) {
    64.                         SetNextState(AttackStates.COOLDOWN);
    65.                     }
    66.                 }
    67.                 break;
    68.             }
    69.         }
     
    khos, Partel-Lang and hopeful like this.
  41. Slowbud

    Slowbud

    Joined:
    Jul 19, 2015
    Posts:
    63
    @Partel-Lang Hello Pärtel, what am I doing wrong. I want to give LookAtIK a new target but nothing happens. The Target field in the LookAtIK component stays at the old, nor does anything else change. Thanks!

    public LookAtIK laIk;
    public Transform targetNpcTrans;

    laIk.solver.IKPosition = targetNpcTrans.position;
     
  42. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,957
    Could be that ikExecutionOrder.IKComponents list was just not created when it was declared;
    Use
    Code (CSharp):
    1. public List<IK> IKComponents = new List<IK>(0);
    istead of
    Code (CSharp):
    1. public List<IK> IKComponents;
    It is a good practice to set default values for all arrays when declaring them.

    Hey,
    The way this works currently is that the character has a collider and it adds every InteractionTrigger it becomes in contact with to InteractionSystem.inContact list. That list is processed by IS to select out the triggers and interactions that are currently in range and that results in InteractionSystem.triggersInRange so you could choose any one of those to start an interaction with. For InteractionTargets there is no range detection separately, it will just choose the InteractionTarget based on the effector that is used for the interaction and the tag is you have "Target Tag" defined in IS. InteractionTrigger is responsible for basically just checking which interaction is in range and choosing which effector to start the interaction with.

    I don't think using spherecast would be any faster, it basically does the same thing as trigger colliders under the hood.
    What you could do instead is make a culling system that deactivates all InteractionTrigger colliders that are too far from the player. You can also make a layer "Interaction Trigger", add a new gameobject with that layer to the character and add the trigger collider on that, assign that collider as to IS "Character Collider" slot. Also move all InteractionTriggers to that layer.

    Hey, thank you so much for stopping by just to say that, much appreciated!
    Good luck with your work and let me know if there's anything I can help you with

    Hey,
    if IK component has a target slot assigned, it will owerwrite ik.solver.IKPosition before each solver update.
    So either remove the Target
    Code (CSharp):
    1. ik.solver.target = null;
    and call
    Code (CSharp):
    1. ik.solver.IKPosition = targetNpcTrans.position;
    or set targetNpcTrans as target:
    Code (CSharp):
    1. ik.solver.target = targetNpcTrans;
    But the easiest woud be to add LookAtController. That is a helper tool that takes care of all the smooth weight blending and target switching and interpolation for you. Please check out the "LookAt Controller" demo.

    Cheers,
    Pärtel
     
    syscrusher likes this.
  43. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    305
    Hi @Partel-Lang Not strictly speaking an asset support question, but I'm hoping you might be able to give me some insights... I'm using VRIK and want to mirror the humanoid rig transforms onto another identical rig.

    I've seen your previous reply to someone wanting to do something similar (https://forum.unity.com/threads/fin...d-ik-1-0-released.222685/page-69#post-3637744) and that works great, but I want to mirror the transforms. i.e. when one puts up their right hand the other puts up their left.

    I've posted a full question with code, on the Help Forums: https://answers.unity.com/questions/1675472/how-to-mirror-avatar-transforms.html

    Any help would be very much appreciated!
     
  44. ibompuis

    ibompuis

    Joined:
    Sep 13, 2012
    Posts:
    57
    Hi,

    I try to use FinalIK with FABRIK on VR project, I'v used the demo FABRIK to test rapidly on device and work nice. Now I try to setup for my one project but I'v some trouble:

    First here is the final state I want when I move Target on VR:

    https://screencast.com/t/c8gObaT6qws

    Here is the initial state:

    https://screencast.com/t/bcRV0AhB4a2

    The part of rig is composed of 3 pivots with limits activated:

    https://screencast.com/t/Eh1W3Oj7mj95

    The fixed part have rotation without limit:

    https://screencast.com/t/rHf6Iz2y

    And the setup of FABRIK

    https://screencast.com/t/fTL65desA

    The result is when I move target, impossible to reach the final state that I want (first screencast), I have tested so many options but without good result.
    Maybe someone can tell me what is wrong on my setup ?

    https://screencast.com/t/hP03Sc3GUf3

    Best,
     
    Last edited: Nov 1, 2019
  45. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,957
    Hey,
    The easiest would probably be just to mirror the IK targets over the YZ plane for the mirrored character and have VRIK do the rest.

    You could also try using HumanPoseHandler. Call GetHumanPose after VRIK is done for the frame (use ik.solver.OnPostUpdate delegate). It will fill in a HumanPose with the current pose for you. You'll then need to invert or mirror some of the muscle values in the HumanPose and use SetHumanPose to write the results on the mirrored avatar. Not sure how to do that mucle mirroring exactly, it will require some experimentation, but should be possible. You can use HumanTrait to get the names of the muscles in HumanPose.

    Hey,
    Looks like you have too many bones assigned to FABRIK. If only the cylinders are supposed to rotate, only use them as FABRIK bones, you can just skip the objects that should not move with the IK.

    But looking at that rig, if closing & opening is all it does, it will be much easier, more efficient and reliable to set it up with simple animation. You can use the Animation Window to make an animation clip of closing the shutter or whatever that is.

    Cheers,
    Pärtel
     
  46. ibompuis

    ibompuis

    Joined:
    Sep 13, 2012
    Posts:
    57
    Thanks Partel,

    Animation is not an option because user need move this object for "reel" :)
    I try to reduce bones like you said and back to you.

    Best,
     
    Last edited: Nov 4, 2019
  47. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    305
    Thanks @Partel-Lang Your help is very much appreciated.

    I'd originally gone down the route of using two VRIK rigs but hadn't been able to make it work, which is why I was just mapping transforms from one to the other.
    Thanks to your guidance I've got a little further but Quaternion maths is a bit out of my league and I'm finding the flipping of the targets a bit tricky.

    After a day of trying I've got this set-up:

    The OffsetTargetIK.cs script is offsetting the targets on the cloned avatar, from the transforms of the targets inside the OVRCameraRig.
    Code (CSharp):
    1. private void Update() {
    2.  
    3.     for (int i = 0; i < transformsToOffset.Length; i++)
    4.     {
    5.      
    6.          if(i==0){ // HEAD
    7.  
    8.             // Mirrors x-axis and y-axis BUT NOT z
    9.             Quaternion headCacheAngle = transformsToFollow[i].rotation;
    10.             Quaternion headInvertedRotation = new Quaternion (-headCacheAngle.x, headCacheAngle.y, -headCacheAngle.z, headCacheAngle.w);
    11.             Quaternion headOffsetRotation = Quaternion.Inverse(Quaternion.Euler(headRotation)) * Quaternion.Inverse(headInvertedRotation);
    12.             transformsToOffset[i].rotation = headOffsetRotation;
    13.  
    14.             // ?? How to mirror all ?
    15.          
    16.  
    17.         } else{ // HANDS
    18.  
    19.             // Y:180
    20.             Quaternion cacheAngle = transformsToFollow[i].rotation;
    21.             Quaternion handsInvertedRotation = new Quaternion (-cacheAngle.x, -cacheAngle.y, cacheAngle.z, cacheAngle.w);
    22.             Quaternion handsOffsetRotation = handsInvertedRotation * Quaternion.Inverse(Quaternion.Euler(handsRotation));
    23.             transformsToOffset[i].rotation = handsOffsetRotation;
    24.  
    25.         }
    26.  
    27.         transformsToOffset[i].position = transformsToFollow[i].position + new Vector3(0f,0f,zOffsetPos);
    28.      
    29.         // ?? Hands z- axis movement is inverted
    30.     }
    31. }
    full code here: https://gist.github.com/baroquedub/859113f84af036c31d0d38a65abce68d

    But the results aren't quite as expected. The Head rotation isn't mirrored on the z-axis, and the movement of the hands on the z-axis is backwards from what it should be:


    I'd really appreciate any further advice you can give to help me figure out where I've gone wrong.
     
    Last edited: Nov 5, 2019
  48. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    305
    I've got the head working using:
    Code (CSharp):
    1. // Mirror all, with reverse on z-axis
    2.                 Quaternion offsetRotation = Quaternion.Inverse(transformsToFollow[i].rotation) * Quaternion.Euler(headRotation);
    3.                 Vector3 targetEuler = offsetRotation.eulerAngles;
    4.                 transformsToOffset[i].rotation = Quaternion.Euler(targetEuler.x,targetEuler.y,-targetEuler.z);
    full code updated: https://gist.github.com/baroquedub/859113f84af036c31d0d38a65abce68d

    Now just the hands' inverted translation on the z-axis to sort out...
     
  49. Wully

    Wully

    Joined:
    Mar 18, 2014
    Posts:
    3
    Hey
    I'm using UMA and VRIK and the Oculus SDK. With a headset and two controllers, no trackers.

    I'm using the OVR Player Controller script in the Oculus SDK to move around.
    When moving it looks like the UMA avatar is being dragged forward and the legs trail behind.
    I've tried tweaking all manner of things but I'm not sure how to get the legs to basically stay under the centre of mass



    A bit off topic, but is there a better way to control VR characters rather than via a character controller?
     
  50. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    305
    @Wully I've been thinking about this a lot recently and would be super interested in other people's thoughts.

    I'm beginning to think that the answer is to use a combinatoin of IK and more traditional mecanim animation (as in 3rd person character controller where velocity and rotation drives a state machine with blending between different animations). You essentially have to do that with hand poses and I think the same applies to the legs.Once the player is static you can revert back to VRIK for solving the leg position.

    Looking at @Partel-Lang 's work on Dead and Buried Arena at Oculus Connect5, it seems to me that that's what's going on. Hopefully he can tell us more :)