IK for Custom Unity Assets

Plugins IK for Custom Unity Assets

Ummmh - any plans on adding IK functionality also for VaM person atoms? (I mean ... since you haven't done that already, I'm assuming there's a good reason why this would be non-trivial - but it doesn't cost to ask ...)?

IK could be ... kinda useful for a VR boinking simulator, I recon ...
 
Ummmh - any plans on adding IK functionality also for VaM person atoms? (I mean ... since you haven't done that already, I'm assuming there's a good reason why this would be non-trivial - but it doesn't cost to ask ...)?

IK could be ... kinda useful for a VR boinking simulator, I recon ...

VAM people already have IK, or am i misunderstanding the question ?
 
VAM people already have IK, or am i misunderstanding the question ?

Ummmmh - they do? To be perfetly honest, I don't know whether you're misunderstand my question, or I'm misunderstanding Inverse Kinematics, or ...? o_O

To the best of my (limited, lay-person-ish) understanding, VaM's person atoms do not have inverse kinematics - a VaM person atom is (amongst many other things) what is called a "system of dampened, coupled, driven harmonic oscillators" in physics. Think a bunch of masses joined by springs - move one mass & the spring connecting its neighors is elongated, resulting in a force acting on both. The force is linearly proportionally to the change in the spring's length ("Hooke's Law"). For each joint, there's also a "controllers" (green nodes) are "virtual" things that are connected to one particular mass ("object") via one spring - but if you move a controller, the spring only acts on its respective object, there is no force that acts on the controller itself.

Say you load a char in the default T-pose, grab the hand's controller and move it - then the whole arm will move, bcs the springs joining hand, ellbow and shoulder (called "arm") get elongated and exert forces on the respective masses. Then the system will move to a new position where all forces are again in equilibrium.

That's ... looks surprisingly realistic - but it's not inverse kinematics. For starters, with a full IK system, the whole body would change posture if the hand's new position is slightly out of reach - like you yourself would lean a bit forward if you tried to grab smth that is just slightly out of your arm's reach.

VaM's person atoms don't do that - if you drag the controller beyond a certain distance .... nothing will happen. Because the other active controllers have stayed in place, and the force they exert on their respective object will simply grow proportionally to the force exerted by the controller you've moved.

(Edit: Come to think of it, I've neglected bones & rigidbodies - afterall, a person atom's are won't stretch if you just pull hard enough. I guess you could simply specify a minimum distance between joints, and set the connecting spring constants to a really high value, but I'm not sure ...)


(Afaics!) Inverse kinematics is a completely different approach - With IK, if you moved the hand controller, the program would automatically compute the correct angle & position of each connected joint in order for the hand to end up in the desired position & orientation. And then, it would drive each joint to assume that value - like your arm would, if you pushed a button in front of you: You don't levitate your hand to the correct position and the ellbow is dragged along; your muscles drive each of your joints to the necessary position & orientation for your finger to reach the button. And if the new position is out of reach of your hand, the whole body would change posture - lean forward eg - or even walk until the new position can be reached.

Afaik, the closest thing to IK in VaM "universe" is the "muscle poses" that miscreated is working on - but iirc, his plugin is not a full IK system (Yet ...).

As far as I know, Unity does have IK capabilities - but only if the "person" is a "valid avatar". VaM's person atoms are composed of Unity gameobjects, and they are articulated kinematic chains, and the joints can be "driven" (like a little moter in each joint) - so I recon the necessary ingredients for IK are there? - but I'm not sure that VaM person atoms satisfy the "valid avatar" definition? If they did, then why didn't Meshed just use those libraries?
 
Last edited:
Ummmmh - they do? To be perfetly honest, I don't know whether you're misunderstand my question, or I'm misunderstanding Inverse Kinematics, or ...? o_O

To the best of my (limited, lay-person-ish) understanding, VaM's person atoms do not have inverse kinematics - a VaM person atom is (amongst many other things) what is called a "system of dampened, coupled, driven harmonic oscillators" in physics. Think a bunch of masses joined by springs - move one mass & the spring connecting its neighors is elongated, resulting in a force acting on both. The force is linearly proportionally to the change in the spring's length ("Hooke's Law"). For each joint, there's also a "controllers" (green nodes) are "virtual" things that are connected to one particular mass ("object") via one spring - but if you move a controller, the spring only acts on its respective object, there is no force that acts on the controller itself.

Say you load a char in the default T-pose, grab the hand's controller and move it - then the whole arm will move, bcs the springs joining hand, ellbow and shoulder (called "arm") get elongated and exert forces on the respective masses. Then the system will move to a new position where all forces are again in equilibrium.

That's ... looks surprisingly realistic - but it's not inverse kinematics. For starters, with a full IK system, the whole body would change posture if the hand's new position is slightly out of reach - like you yourself would lean a bit forward if you tried to grab smth that is just slightly out of your arm's reach.

VaM's person atoms don't do that - if you drag the controller beyond a certain distance .... nothing will happen. Because the other active controllers have stayed in place, and the force they exert on their respective object will simply grow proportionally to the force exerted by the controller you've moved.

(Edit: Come to think of it, I've neglected bones & rigidbodies - afterall, a person atom's are won't stretch if you just pull hard enough. I guess you could simply specify a minimum distance between joints, and set the connecting spring constants to a really high value, but I'm not sure ...)


(Afaics!) Inverse kinematics is a completely different approach - With IK, if you moved the hand controller, the program would automatically compute the correct angle & position of each connected joint in order for the hand to end up in the desired position & orientation. And then, it would drive each joint to assume that value - like your arm would, if you pushed a button in front of you: You don't levitate your hand to the correct position and the ellbow is dragged along; your muscles drive each of your joints to the necessary position & orientation for your finger to reach the button. And if the new position is out of reach of your hand, the whole body would change posture - lean forward eg - or even walk until the new position can be reached.

Afaik, the closest thing to IK in VaM "universe" is the "muscle poses" that miscreated is working on - but iirc, his plugin is not a full IK system (Yet ...).

As far as I know, Unity does have IK capabilities - but only if the "person" is a "valid avatar". VaM's person atoms are composed of Unity gameobjects, and they are articulated kinematic chains, and the joints can be "driven" (like a little moter in each joint) - so I recon the necessary ingredients for IK are there? - but I'm not sure that VaM person atoms satisfy the "valid avatar" definition? If they did, then why didn't Meshed just use those libraries?

So my short answer would be VAM appears to have IK per limb but not full body IK, though full body ik is clearly possible as demonstrated by the plugins miscreated has made. if you move a hand the elbow moves to where you'd expect it to move.. just like a regular LimbIK in FinalIK. So I think to say VAM models don't have IK is incorrect, do they have full body IK not from what I can see. But, that might simply be a feature Meshed has chosen not to turn on. For example in FinalIK full body controller you can make the head controller pull the body instead of the arms.. its just a config option(and its in the plugin). Doing so would exhibit behavior unlike what you describe above as IK. So I guess to know for sure you'd have to ask Meshed :).

Hope that helps!
 
imakeboobies updated IK for Custom Unity Assets with a new update entry:

Animation support + subscene fixes

-Added animation support via the BVH plugin
-Fixed subscene support(specifically if you've just created the subscene)
-Added a look at Effector separate from the head effector.
-Added a bunch of additional API methods to provide the ability to turn on/off the IK features from other plugins.

Video of the IKCUA within a typical workflow: https://www.erome.com/a/8X8aVqvA

Read the rest of this update entry...
 
Works amazingly except I cant get BVH's to play , the Head tracks, I can manually move the limbs but BVH's just show a black skeleton dancing by its own... do you have any sample BVH files I could trial and error with?
 
1643451177722.png


As you can see the character poses just fine, but I can't BVH anything T_T
 
I can't find spine. Does all models has different set up?
1643596510959.png


And some selection panel is greyed out can't click on it. How do you rig this xnalara model? Is there any tutorial?
 
I can't find spine. Does all models has different set up?
View attachment 93351

And some selection panel is greyed out can't click on it. How do you rig this xnalara model? Is there any tutorial?
Unfortunately some models aren't rigged properly.. or rather they are rigged for XNALara and not unity. This looks to be one of those cases. If the bones are not in a hierarchy that makes sense to unity you can't really get them to work in IK.

In terms of why some drop downs are greyed out, its because the plugin expects values in the above nodes before it can figure out what options to show you in the below nodes.
 
Unfortunately some models aren't rigged properly.. or rather they are rigged for XNALara and not unity. This looks to be one of those cases. If the bones are not in a hierarchy that makes sense to unity you can't really get them to work in IK.

In terms of why some drop downs are greyed out, its because the plugin expects values in the above nodes before it can figure out what options to show you in the below nodes.

So is there anyway to rig it somehow? Any tuts?
 
So is there anyway to rig it somehow? Any tuts?
you have a few options:

1. Fix in XNALara, you'll have to google how to do this as its not a tool i know
2. Import to Blender and fix there, then import as a CUA via unity. Lots of tuts on that on the hub.
3. Find someone else who has rigged the same model on deviant art

sorry best i can do for you! Sadly with such a lot of models out there some just don't work great.
 
Hi, I don't know if I use it right, but I have issue with capsule collider :
- I rig a snake in blender
- imported to unity
- set as character joint (last bone = head), and tail bone is fisrt bone.
- add a capsule collider to an emptyobject parented to last bone (head) (with this I can rotate the capsule collider to align with the head)

- import to VAM and set IKCUA and select FABBRIK and last bone and add bone. The effector don't do anything

- If I don't add the capsule collider, I can move the head with the effector.

Is it capsule collider specific issue ? or do I do something wrong ?

If I use limbIK, it's OK but I need to set 3 bones.

EDIT : I found the issue. It's caused by the emptyObject. If add directly the capsule to the bone, it works ! (but I lost the possibility to rotate the capsule).
 
Last edited:
Hi, I don't know if I use it right, but I have issue with capsule collider :
- I rig a snake in blender
- imported to unity
- set as character joint (last bone = head), and tail bone is fisrt bone.
- add a capsule collider to an emptyobject parented to last bone (head) (with this I can rotate the capsule collider to align with the head)

- import to VAM and set IKCUA and select FABBRIK and last bone and add bone. The effector don't do anything

- If I don't add the capsule collider, I can move the head with the effector.

Is it capsule collider specific issue ? or do I do something wrong ?

If I use limbIK, it's OK but I need to set 3 bones.

EDIT : I found the issue. It's caused by the emptyObject. If add directly the capsule to the bone, it works ! (but I lost the possibility to rotate the capsule).

So the way the FABBRIK and CCD solvers work is to try and find a path to the last transform. As soon as there's multiple paths it's not sure which to take it stops and assumes that's the end of the hierarchy. I did put in logic to say if you've got 2 children and one has more children and the other doesn't then use the one with children but it seems like its not working in your case.

I had planned on expanding the logic to look past the immediate children.. its a fun comp sci problem solve that im sure i did at university at some point!
 
Hi, I have this applied to a model but I want to move the effectors by script. Because I only want one script and there are many effectors, how do I find each one and set it's position via script?
Thanks again for this awesome plugin ;)
 
Hi, I have this applied to a model but I want to move the effectors by script. Because I only want one script and there are many effectors, how do I find each one and set it's position via script?
Thanks again for this awesome plugin ;)

The BVH plugin does something similar. First you have to check that the IK has been fully setup. I do this in post restore as i know all the atoms will have been spawned then. Have a look at this code:


Once that is done you can go and use this code to get the list of effectors:


The return bindings will execute this function in the IKCUA plugin:


I need to expand it a bit to get you back all the non-full body effectors and the look at target, will do that in the next release sometime this week.
 
Thanks I will take a look through those. What I want to do is in theory simple but proving hard, it's just I don't understand the scripting language enough.
I have this,
rightHandStorable = GetAtomById("1&RightHand&172201FBBIK_Effector")?.GetStorableByID("control");

Which I assume is working.

Then I use this to move the hand,
tempx = rightHandStorable.GetFloatJSONParam("x");
tempx.val = jointPositions[10].x;

but the effector/hand doesn't seem to actually move when I change that value.
 
Thanks I will take a look through those. What I want to do is in theory simple but proving hard, it's just I don't understand the scripting language enough.
I have this,
rightHandStorable = GetAtomById("1&RightHand&172201FBBIK_Effector")?.GetStorableByID("control");

Which I assume is working.

Then I use this to move the hand,
tempx = rightHandStorable.GetFloatJSONParam("x");
tempx.val = jointPositions[10].x;

but the effector/hand doesn't seem to actually move when I change that value.

You're changing the json value but not the actual transform position. Try this:

rightHandStorable.transform.position = new Vector3(jointPositions[10].x, rightHandStorable.transform.position.y, rightHandStorable.transform.position.z);

Assuming your setting a global postion. If its local then use localPosition instead.
 
Hey, great work! I've wished for something like this for a long time. Thank you also for you very verbose and friendly explanations, I really appreciate them. Would it be possible to add multiple effectors/bones with FABRIK solvers? As far as I can see, Final IK supports applications like that. That'd be really helpful for more complex tentacle animations or maybe even robot arms.
 
Hey, great work! I've wished for something like this for a long time. Thank you also for you very verbose and friendly explanations, I really appreciate them. Would it be possible to add multiple effectors/bones with FABRIK solvers? As far as I can see, Final IK supports applications like that. That'd be really helpful for more complex tentacle animations or maybe even robot arms.

Yeah its definitely a feature i could add. I'd originally gone with the simplest implementation(eg just a single path to traverse) to make it easy for folks to use. But I could do something like start/end bone segments within a hierarchy and then add effectors at each end bone. Is that kind of what you meant ? It'd allow you to actually do things like wrap a tentacle around a limb.. or other things ;)
 
Yeah its definitely a feature i could add. I'd originally gone with the simplest implementation(eg just a single path to traverse) to make it easy for folks to use. But I could do something like start/end bone segments within a hierarchy and then add effectors at each end bone. Is that kind of what you meant ? It'd allow you to actually do things like wrap a tentacle around a limb.. or other things ;)
Yes! That's what I was going for.
 
You're changing the json value but not the actual transform position. Try this:

rightHandStorable.transform.position = new Vector3(jointPositions[10].x, rightHandStorable.transform.position.y, rightHandStorable.transform.position.z);

Assuming your setting a global postion. If its local then use localPosition instead.
Thank you! This worked!
I am still getting odd results though. While I can move the hands and feet fine, when I try and move the knees/elbows etc the model seems to lock up and do odd things. I can move them manually with the cursor and the knee will move as expected, but when I try and position it by script it locks up.

I clearly have a lot to learn :( This whole IK thing is completely new to me.
 
Previous versions of plugin did not have naming filter for bones. Kind of wish to still be able to assign bone names manually, since some models name bones differently.
One more thing - are there any bending poles for elbows, knees to correct the deformation of limbs?
Thank you.
 
Last edited:
Hi... How could I use your plug in with this??? https://hub.virtamate.com/resources/black-dragon.5067/
Ive been able to add some bones to it in the spine and neck. but there are somethings it seams that do not transfer and it took a while to sort out the names of the bones. I tried it with the full skeleton and when I got to applying arms and things past the tail, it stopped and I couldnt add anymore to it. I'm not sure which type of skeleton it should be switched to and I'm hoping that this could then be edited in the time-line to attack some peeps in a scene i was starting.. Was your plug in made for this anyway? and what could I use instead that was for this more specifically?

If there was a dragon or some kind of fantasy creature morph that would just make everything way easier, but I havn't ran into any kind of morph plug-in that does anything besides elfs, orcs or the horse head.



some time later i checked out xps files on diviant art. im a bit confused as how to download a xps file now.. all I see are jpgs of animae girls from doa and old games like that. I'm not sure what a xps file is.. or how to get it in vam ..
 
Last edited:
Back
Top Bottom