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

Hey,
Please use this link to download the package updated to Orion.
It will be added to FinalIK/_Integrations in the future…

Cheers,
Pärtel

@Partel-Lang Hi, I’m trying to use Limb.IK to throw a grenade from the view of FP, my problem is the arm has a Bip01 L ForeTwist bone that is screwing up the movement when I use Limb.IK

2572051--179476--Screen Shot 2016-03-28 at 10.38.17.png

Is there another way to bypass this bone?

I use the …

Bip01 L UpperArm
Bip01 L Forearm
Bip01 L Hand

In the Limb.IK chain.

Thanks.

Hey,
It’s a problem with Max Biped twist bones, the forearm twist bones are weirdly not parented to the forearm and the hands are not parented to them.
You should be able to solve this issue if you store the position/rotation of the twist bone relative to the forearm in LateUpdate before LimbIK solves, and move the twist bone back to the same relative pos/rot after LimbIK has solved.
Something like this:

public LimbIK limbIK;
    public Transform twistBone;

    private Vector3 relativePosition;
    private Quaternion relativeRotation;

    void Start() {
        // Take over the LimbIK's solver
        limbIK.enabled = false;
    }

    void LateUpdate() {
        // Remember the position/rotation of the twist bone relative to the forwearm
        relativePosition = limbIK.solver.bone2.transform.InverseTransformPoint(twistBone.position);
        relativeRotation = Quaternion.Inverse(limbIK.solver.bone2.transform.rotation) * twistBone.rotation;

        // Solve IK
        limbIK.solver.Update();

        // Transform the twist bone back to how it was relative to the forearm before solving IK (as if it was parented to the forearm)
        twistBone.position = limbIK.solver.bone2.transform.transformPoint(relativePosition);
        twistBone.rotation = limbIK.solver.bone2.transform.rotation * relativeRotation;
    }
1 Like

@Partel-Lang line 21 is missing a capital T for transformPoint otherwise worked perfect … Thank you.

Hi Partel,

I want to create a app in which user have a T-Pose model and let them to create a pose as they wish. just by drag or some button. They can manipulate hand, wrist, leg, knee or head. I have added FBBIK on model and give target to every part and dragging that target, everything working but one thing body parts overlapping each other and realistic pose could not be created. Can you suggest me how can this be possible and if i am doing wrong please tell me how can i achieve this.
I want to create poses like this.

Thanks for the quick response Partel - edit: taken a bit of fiddling but im getting quite satisfied with the results!

Hi Partel,

When I set up AimIK on a character and hit play on a scene then there is a noticeable 0.5 second or so lag before the character ‘snaps’ to the configured target. I notice the same thing on the AimIK demo scene ‘Aim Weapon’.

I am assuming its because the solver takes a bit of time to initialize and only updates the animation after a few updates have taken place already?

Are there any workarounds for this when you have a scene that starts off with an aim pose to a specific target?

Thanks,
Albert

Hi!

There’s no easy solution for this I’m afraid.
You might want to try multiple iterations of solving. So FBBIK normally can’t use rotation limits. But you could set up rotation limits anyway, solve FBBIK once, apply the rotation limits and solve FBBIK again on top of that (or LimbIK, which is faster). So basically you would iterate towards a result where both IK targets are met and rotation limits satisfied. It would get quite heavy performance-wise though, which is why such a solution is not implemented in Final-IK. But if you only have one or two characters to solve on decent hardware, it should be OK.

You can take control of IK and RotationLimit components by disabling them in Start and calling ik.solver.Update() and rotationLimit.Apply() whenever you need.

Hi!
It seems to be a problem with the Animator. Rotating any bones controlled by the animator seem to make no difference for that short amount of time. AimIK initiates instantaneously in Start and updates in LateUpdate of the first frame. You can try it with a simple script like that:

public Transform bone;

    void Awake() {
        bone.rotation = Quaternion.LookRotation(Vector3.right);
    }

    void Start() {
        bone.rotation = Quaternion.LookRotation(Vector3.right);
    }

    void LateUpdate() {
        bone.rotation = Quaternion.LookRotation(Vector3.right);
    }

If you assign the root of the character as the “bone”, you’ll see the change applied to it’s rotation instantly. If you assign any of the character’s bones, you’ll see the short delay before it becomes visible, no matter how early you run it, even in Awake.
It will become instant though if you disable the Animator so it must be the Animator overwriting the pose.

Cheers,
Pärtel

Hey Partel, FinalIK is awesome - I’ve been making use of the grounder and interaction IK systems for a while in a project and they’ve worked great for human characters. I was wondering about how easy it would be to set up for more complex/less conventional joint chains though.

I’ve got this robotic arm in the game (part of a futuristic medical facility), and I’d like to drive itusing IK:


I’ve got it set up with the LimbIK script at the moment, and this works well for the top two joints, as long as I keep the target along the same plane as the arm. As you can see from the image though, those two joints should only be able to rotate along the X axis, and there’s a joint at the very bottom that can tilt the arm along the Z axis. Is there a simple way to get the IK system to use these joints correctly?

EDIT: After playing around with it more, I’ve switched to CCDIK, using rotation limits on each of the joints and this works much better, but there’s still one strange thing (which may just be a limitation of the IK solver, I’m not sure).

When the target is moved parallel with the track the arm is on, the arm gets tilted (at the base) towards the target, but as the rotation takes place at the bottom of the chain, this leaves the end of it pointing away from the target. If the base tilted away from the target, the end would be able to get much closer.

I realise this is probably something of an edge case, but is there anything I can do?

Thanks!

Hi Partel,

Thanks for the info. I also use Chronos and it too has confirmed issues related to the animation system behaving unexpectedly.

Would be good if we could grab the attention of the Unity Animation guys to have a look at these issues. I suppose I could log an issue but don’t think it would carry as much weight as unity asset store heavy weights. :wink:

Hi Partel,

I am battling a bit to get a character animation scenario using FinalIK to work properly and was hoping you may have advice / tips for me to help nail it.

I have a character holding a rifle in a default relaxed pose like so:

When aiming it needs to transition to the following pose:

Before aiming I want it to look at the target, which is easily achievable using Look At IK:

My challenge is to get Aim IK to weigh in during the transition from relaxed pose to aiming pose, so that as the character lifts the rifle it should already ‘lerp’ towards the target so that when coming to rest in its aim pose the character is aiming directly at the target.

If I weigh in Aim IK it will not give me the effect I am after since the aim transform is not pointing to the target thus the spine will be bent, as expected.

You have a demo where you do a 360 aiming system using a direct blend tree, but in this case there are animation nuances (relaxed to aim and aim to relaxed animations) that will get lost if I simply blend between the two static poses.

Any ideas? :slight_smile:

Hey!
Are you using some code to tilt the base or is it done by the solver? Have you tried adjusting bone weights?

Alright, no prob, I’ll make a bug report…

You can play an animation of going from idle to aim and still use AimIK on top of that the whole time. You’ll just have to adjust the Axis of AimIK, tell it that whatever pose the character is in, it is aimed forward.
That’s all the code you’ll need:

public Vector3 aimDirection = Vector3.forward;
void LateUpdate() {
        aimIK.solver.axis = aimIK.solver.transform.InverseTransformDirection(character.rotation * aimDirection);
}

That enables you to also play reloading and recoil animations while aiming with AimIK. You might have to adjust aimDirection in the Editor to fix accuracy.

Cheers,
Pärtel

You sir are a gentleman and a scholar! Awesome.

There is one artifact to using only this code though. When the target sits above or below the character the spine gets bent into an unnatural pose when idle:
(No Look IK applied)

When aiming the pose looks a lot more natural:

When turning off Aim IK and enabling Look IK I get a very natural idle pose while looking at the target:

Is there an eloquent way you can think off to solve this so that I can get the natural pose provided by Look IK when in idle mode but still have all the wholesome goodness of the aiming during the animation transitions?

1 Like

You could link AimIK.solver.IKPositionWeight to your aiming animation weight.

1 Like

Cool. Using your tip as a starting point I scanned the previous posts and found a similar question was asked before. FinalIK’s forum postings a bit daunting at 36 pages :slight_smile:

So I started playing around with the above and managed to get fairly good results by using Curves for blending in and out. I realized during the process that for extreme angles etc. I would need to get a bit more sophisticated, but I’ll take a similar approach than your 360 degree aiming sample to polish it out.

The quick-and-dirty code looks like this:

using System.Collections;
using UnityEngine;
using RootMotion.FinalIK;

[RequireComponent(typeof(Animator))]
[RequireComponent(typeof(AimIK))]
[RequireComponent(typeof(LookAtIK))]
public class AimCorrector : MonoBehaviour 
{
    public Vector3 aimDirection = Vector3.forward;
    public AnimationCurve AimIKAiming;
    public AnimationCurve AimIKRelaxing;
    public AnimationCurve LookIKWeightAiming;
    public AnimationCurve LookIKWeightRelaxing;
    public AnimationCurve LookIKBodyWeightAiming;
    public AnimationCurve LookIKBodyWeightRelaxing;

    private bool lastAimingValue;
    private Animator animator;
    private AimIK aimIK;
    private LookAtIK lookAtIK;
    private float curveTime = 0.0F;

    void Start ()
    {
        animator = GetComponent<Animator>();
        aimIK = GetComponent<AimIK>();
        lookAtIK = GetComponent<LookAtIK>();
        lastAimingValue = IsAiming;
    }

    void LateUpdate() 
    {
        if(lastAimingValue != IsAiming)
        {
            curveTime = 0.0F;
            lastAimingValue = IsAiming;
        }

        curveTime += Time.deltaTime;

        aimIK.solver.axis = 
            aimIK.solver.transform.InverseTransformDirection(gameObject.transform.rotation * aimDirection);

        if(IsAiming)
        {            
            aimIK.solver.IKPositionWeight = AimIKAiming.Evaluate(curveTime);
            lookAtIK.solver.headWeight = LookIKWeightAiming.Evaluate(curveTime);
            lookAtIK.solver.bodyWeight = LookIKBodyWeightAiming.Evaluate(curveTime);          
        }
        else
        {
            aimIK.solver.IKPositionWeight = AimIKRelaxing.Evaluate(curveTime);
            lookAtIK.solver.headWeight = LookIKWeightRelaxing.Evaluate(curveTime);
            lookAtIK.solver.bodyWeight = LookIKBodyWeightRelaxing.Evaluate(curveTime);
        }
    }

    private bool IsAiming
    {
        get
        {
            var result = animator.GetBool("IsAiming");
            return result;
        }
    }
}

1 Like

Hey, glad you got it working and cheers for posting the solution too! :slight_smile:
Pärtel

Quick general question, your package looks great, and I want to persuade my company to get it, but I just want confirmation: would Final IK be able to do just Hand IK, so that you could dynamically grab objects of different shapes with a hand (that is not attached to a body, just the hand on its own) and defined “finger grab point”?

I’m pretty sure this package could, just would like to double check :slight_smile:

Thanks, yeah - it’s all being done by the solver. I actually semi-fixed it by just adding an extra joint to the arm, so it can swivel around the base too, I think it was more of a problem of the limits making it impossible to reach most positions that it was trying to.

Hi Partel,

I am using your plugin Final IK and found it a very useful and powerful for my work.
I am struggling from few weeks and has been stuck to a following problem.
Please can you help me out? It will be a great favor :slight_smile:

Problem:

I am developing a dance application where user can move its limbs (Effectors) on tapping nearby areas.
I have done my work regarding movements using Interactions. I creates an InteractionObject and starts interaction of selected effector. It going well as my effector moves towards that InteractionObject and returns to its default position.

The problem I am facing is :
I want to change default position of an effector on runtime. So that interaction start from that assigned default point and returns to it, (not to the default position assigned in start)

Hi!
Yes, it is the LimbIK component you are looking for.

Hey,
You should be able to use effector.positionOffset for that.

effector.positionOffset += desiredPosition - effector.bone.position;

(Using += instead of = here because the solver resets positionoffsets to zero after each update, this enables for multiple simultaneous offset modifiers applied on top of each other)

Cheers,
Pärtel