Obtaining the relative size of a Models body part

Hello there,

I am trying to calculate the xyz position of “important” regions on my models, I am doing this by:

Transform [] allChildren = this.transform.GetComponentsInChildren<Transform>(); 
foreach (Transform child in allChildren)
{
           Vector3 objectPos = child.transform.position;
}

However this only gives me an xyz coordinate of the center of each object. However what I need is the xyz coordinates of points like the elbow and shoulder, instead of these I am actually obtaining the xyz coordinates of the center of the upper arm.

One way I can see of obtaining the coordinates I need would be to obtain the size of the upper arm and then extrapolate the location of the Shoulder and elbow from that.

How would I go about obtaining the size of the body part to calculate this? I’m pretty stumped right now.

Note: I am using this Model

Hello,

As you might have noticed this is nowhere near as simple as it sounds. Your solution would require you to analyse the mesh data of that object. If you are confident enough to be able to find the vertices that make up the elbow, then find their size, go for it. But I presume that is beyond your capabilities (gathering from the code you posted)

A much simpler and elegant solution is to have an empty object representing the elbow point as a child of the elbow joint. Getting the “xyz” position of that points would be as simple as grabbing a reference of that objects Transform component and doing Transform.position.

Hope this helps,
Benproductions1

PS: If you do want a solution to actually find the size of the elbow, I can give you more detail to one I just came up with :wink: