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

Hy, fholm, welcome! :slight_smile:

When I started making FBIK, I never even dreamed it could be used on 100 characters at the same time - after all, it is Full Body IK! So actually it was quite shocking to make that performance video.

Anyway, point being, normally in most cases you would need FBIK only on a couple of characters, the ones that are actually doing something that requires for it and that are close enough to the screen to even notice it. And of course you can smoothly blend out FBBIK for the characters in the distance or the ones who have been culled.

Can I ask, what kind of scenario do you have in mind, where you’d need 100 FBIK characters?

Here are the screenshots you asked for:
100 characters with the default normal FBBIK settings:
1486267--82691--$100 Characters Normal IK.png

The same with minimum FBBIK settings:
1486267--82692--$100 Characters Low IK.png

… and with no IK at all:
1486267--82693--$100 Characters No IK.png

@ Whippets

If you are getting the “FBIK Chain contains no nodes” warning, you are probably adding the component without immediately calling SetReferences after. If you don’t call SetReferences in the same frame, FBBIK component will try to initiate it’s solver and throw’s the warning if it has no bones to initiate.
So the IndexOutOfRangeExceptions happen, because you are trying to access the effectors of a solver that has not been initiated yet.

Thats probably because you have the GameObject you are adding it to selected. You see when the GameObject is selected, and you add the component somehow, the custom inspector for FBBIK get’s it’s OnEnable () call, sees that the character has no references, and auto-detects them. If the GameObject is not selected, there will be no OnEnable and the references remain undetected.

Hi,

Would you mind creating a demo for the non programmer types out there that has a character following the mouse or an object in game mode? This is probably trivial for you guys but would be beneficial to the newbies like me. Perfect example scene would have something similar to this:

  1. The dummy rigged up
  2. Objects that you can click on and/or move in the game window that the dummy either reaches toward or otherwise reacts to
  3. a gui button that toggles it to where the dummy reaches or looks/reacts towards where the mouse is
  4. objects that are clickable that the dummy reaches towards or looks like he is going after

This would not have to be anything intricate just the very basics so that non-programmers can snatch the code and mutilate it to make it work for their needs :slight_smile:

Best Regards,

Lee

Thats is a great idea, Lee, thanks! :slight_smile:

I’m on it…

Thanks for all your help, Partel :slight_smile:

I now have realtime emotes in 12 lines of code each… this is too easy XD

New tutorial up! This one is about the alternative uses of Aim IK. I’m discovering that it is a very powerful component and the stuff you can do with it goes far beyond aiming weapons… :slight_smile:

…And here is the code for this tutorial:

using RootMotion.FinalIK;

/// <summary>
	/// Raycasting to the ground to redirect upper-body animation based on ground topography.
	/// </summary>
	public class TerrainOffset : MonoBehaviour {
		
		public AimIK aimIK; // Reference to the AimIK component
		public Vector3 raycastOffset = new Vector3(0f, 2f, 1.5f); // Offset from the character, in local space, to raycast from
		public LayerMask raycastLayers; // The layers we want to raycast at
		public float min = -2f, max = 2f; // Min and max for the offset
		public float lerpSpeed = 10f; // The speed of lerping the IKPosition to make things nice and smooth

		private RaycastHit hit;
		private Vector3 offset;

		void LateUpdate() {
			// Find the raycastOffset in world space
			Vector3 worldOffset = transform.rotation * raycastOffset;

			// Find how much higher is the ground at worldOffset relative to the character position.
			Vector3 realOffset = GetGroundHeightOffset(transform.position + worldOffset);

			// Smoothly lerp the offset value so it would not jump on sudden raycast changes
			offset = Vector3.Lerp(offset, realOffset, Time.deltaTime * lerpSpeed);

			// The default offset point at the character's height
			Vector3 zeroOffsetPosition = transform.position + new Vector3(worldOffset.x, 0f, worldOffset.z);

			// Make the Aim Transform look at the default offset point (So when we are on planar ground there will be nothing for Aim IK to do)
			aimIK.solver.transform.LookAt(zeroOffsetPosition);

			// Make Aim IK bend the spine by the offset.
			aimIK.solver.IKPosition = zeroOffsetPosition + offset;
		}

		private Vector3 GetGroundHeightOffset(Vector3 worldPosition) {
			// Visualize the raycast
			Debug.DrawRay(worldPosition, Vector3.down * raycastOffset.y * 2f, Color.green);

			// Raycast to find how much higher is the ground at worldPosition relative to the character.
			if (Physics.Raycast(worldPosition, Vector3.down, out hit, raycastOffset.y * 2f, raycastLayers)) {
				return Mathf.Clamp(hit.point.y - transform.position.y, min, max) * Vector3.up;
			}

			// Raycast found nothing so return zero
			return Vector3.zero;
		}
	}
2 Likes

Awesome, will definitely put that to good use :wink: Thanks for this tutorial (and script).

Partel, thanks for doing that tutorial, that’s just what I needed.

I’ve just purchased Final IK and imported it into Unity, I went to add Aim IK to my model and it gave me the error -

Instance of AimIKInspector couldn’t be created. The script class needs to derive from ScriptableObject and be placed in the Assets/Editor folder.

As you may have already guessed I’m writing in Javascript, do I need to move all the scripts to the Editor Dir? or only certain ones?

Thanks.

Hi Griffo, thanks for having trust in Final IK :slight_smile:

I believe with Javascript you are supposed to maintain all the editor scripts inside an Editor folder that is not inside the Plugins folder. So if what you did was just moved the entire package to the Plugins folder, you should drag every script that is under Editor folder back out, make a folder Assets/RootMotion/FinalIK/Editor and put them there. I can’t confirm on that at the moment, because I got to go, but you can quickly try this with just AimIKInspector and see if the error changes to another script. then you’ll know it works. If it doesn’t, let me know.

Sorry, I haven’t touched Javascript for years now :smile:

Cheers,
Pärtel

I have trust in Final IK because of the support, first class.

Done what you said and all errors have gone, I’ll start using it tomorrow as now I hear a beer down the pub calling my name … :slight_smile:

Thanks for the help.

you succeeded in what mecanim team failed to deliver
worth the price. good luck with the sales
customer request : integrate it with PlayMaker (add PlayMaker actions)

@OP
Your product looks more and more like an integrated tool of Unity. Very professional. :sunglasses:

Ah, seconded. I completely forgot to ask for Playmaker Integration. Heck at this point I feel any and all significant Assets that have a even a modicum of complexity should support Playmaker. It’s damn near a staple of Unity development! :smile:

Thanks for the feedback, guys :smile:. I will add Playmaker support. It’s going to take some time though I haven’t even tried that thing yet… :slight_smile:
Character System is also one of the things that I’m planning to test Final IK with. Do you guys have any other 3rd party packages that you’re interested in?

Cheers,
Pärtel

Purchased!!!

Mr Partel Lang you’re a genius!

And very professional indeed.

I’ve been watching those youtube video tutorials you made and man this is truly awesome… you’re awesome!!!

That’s the keyword,…

playMaker, once it’s supported I’m getting this aswell :wink:

Hi,

First, thanks Partel for those awesome features, I was checking the assets store as often as possible to buy it first… but I had to update Unity xD
I’ve started to use the FBBIK component to fix an animation (riding a motorbike, hands and feet were not at the correct position, depending of the characters) and it was very easy to do with FinalIK, thanks again :slight_smile:

But there are two things I tryed to do :

  1. With FBBIK, there is a value “Maintain Rotation Weight” for the head, I did not found how I can update this value in a script.
  2. With LookAtIK, I did not found how I can update the position to look at in a script

Edit : I found the solution for the second question, it is similar to FBBIK :
I added this line :
public LookAtIK ikLootAt;
To update the position :
ikLootAt.solver.IKPosition = theLookAtPosition;
Save the script and grab the character on “ikLookAt” in the inspector

Edit 2 : About my first question “maintain rotation weight” for the head with a FBBIK, in script :
ik.solver.boneMappings[0].maintainRotationWeight = 0.5f;

ik is a public FullBodyBipedIK (public FullBodyBipedIK ik; )
I tryed with boneMapping[5] first, cause the head is the 6th element in the “Mapping” area in the inspector=> out of range
Then I tryed boneMapping[0] and it worked :slight_smile: You’re website is awesome as your package Partel ! I’ve found solutions in the class index pages.

Wow, Staff Pick and the reviews! That just made my day (and week and month…) I’m humbled to the ground, that means a lot! Thanks You guys :slight_smile:

@ Rohac
That’s because behind the scenes the FBBIK setup is much more complex than what you see in the inspector. I just wanted to keep the inspector as simple and visually clean as possible for ease of use. In the next version I’ve already added better shortcuts for the mapping, so you could use ik.solver.leftHandMapping and ik.solver.headMapping and so on.

IKPosition and IKPositionWeight is always a good place to start for looking, because they belong to IKSolver that is the base class for all IK solvers in Final IK.

I will improve the User Manual about the properties, perhaps add a “getting started with scripting” section to each component. Thanks for the feedback!

Cheers,
Pärtel

I too was having the same trouble as Rohac in 2) with LookAtIK I thought this would work but I get an error at line 11 -

NullReferenceException: Object reference not set to an instance of an object

#pragma strict

var player : Transform;

private var theLookAtPosition : Vector3;
private var ikLootAt : RootMotion.FinalIK.LookAtIK;

function LateUpdate () {

	theLookAtPosition = player.position;
	ikLootAt.solver.IKPosition = theLookAtPosition;
}

Why :frowning:

And Partel a “getting started with scripting” section to each component sounds good for noobs like me :smile:

EDIT -
Works now I forgot to add -

function Awake(){

	ikLootAt = GetComponent(RootMotion.FinalIK.LookAtIK);
}

Of course the 3rd person controller that is in the new standard asset package.

http://forum.unity3d.com/threads/223158-New-Standard-Assets-a-k-a-Sample-Assets-Beta-Release