- Home /
How can I access Human Avatar bone and muscle values from a script
I have humanoid model that I used to create a Mecanim humanoid avatar, including adjusting the muscle limits. I am trying to manually animate the model using the rig and a combination of IK scripting and/or direct translation and rotation of the model's bones as accessed from the model's Animator component.
Unfortunately, all of the above seem to completely ignore the rig's muscle limit values.
I see that there are classes like HumanLimit, HumanTrait, HumanDescription, etc. that seem to be for the purpose of programmatic creation of human Mecanim avatars, but I'm not able to find any methods for getting any of the values from an already-created avatar (created with the Unity editor or otherwise). Rather than manually clamping all my rotations to the limits I want, is there some way to simply apply the avatar's limits to rotations using IK or Rotate() or any other manual movements of the model?
Hi, I read your issue with interest, I have a similar issue, but I'd like to ask how did you adjust the muscle limits? I want to limit leg movements to say 10% ins$$anonymous$$d 90% angles/movement? Any advise would be most appreciated.
I gave up and ended up using blender to make animations, wow what a learning curve that is.
Answer by tinyant · Jul 06, 2017 at 06:53 AM
public static bool GetHumanDescription(GameObject target, ref HumanDescription des)
{
if (target != null)
{
AssetImporter importer = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(target));
if (importer != null)
{
Debug.Log("AssetImporter Type: " + importer.GetType());
ModelImporter modelImporter = importer as ModelImporter;
if (modelImporter != null)
{
des = modelImporter.humanDescription;
Debug.Log("## Cool stuff data by ModelImporter ##");
return true;
}
else
{
Debug.LogError("## Please Select Imported Model in Project View not prefab or other things ##");
}
}
}
return false;
}
you can get the HumanDescription information by $$anonymous$$odelImporter. https://docs.unity3d.com/ScriptReference/HumanDescription.html
I am trying get the Human muscle values.