- Home /
Custom Ragdoll Autorigger Setup
Scenario : I am writing a custom ragdoll setup script I can drop on any rig that will take joint chains tagged with "Rig" on the joint object to indicate that the joint/joint chain should be set up with rigidbody, capsule collider and character joint. The joint lengths and transform can be derived from standard algorithms of angle and distance from parent to child objects.
Question : The capsule collider is scaled to match the joint of the rig when done manually. No problem there. In a script however there are no units to use to determine scale back and forth..meaning the joint comes in imported at a scale of 1,1,1 and the collider is scaled at 1,1,1 but they rarely if ever match up dimension wise. What i want to do is find the length of the joint from root to tip, scale the collider to that length and move it half the joints length down the z axis so the joint and collider are properly overlapped. My issue is where do I or how do I extract the information needed to ensure my scaling is correct in regards to bone length. With measured units it would be a breeze but I can have a joint 1 unit long that is scaled to 1 or a joint 1000 units long and it is still scaled to one.
Have you finished this yet? Because it sounds extremely useful
Answer by StephanK · Jun 21, 2010 at 05:42 PM
A collider's height is set using the "height" property. Scaling is only a factor applied to this. To get the "real" length of a joint in a correctly setup rig it's enough to set the scale to 1 and measure the distance between a child and a parent. (e.g. float lengthOfLowerLeg = Vector3.Distance(knee.transform.position, ankle.transform.position))
Thanks for the heads up. I overlooked the height property.
Your answer
![](https://koobas.hobune.stream/wayback/20220613062631im_/https://answers.unity.com/themes/thub/images/avi.jpg)