I’ve found the following code for drawing the bones in an armature (performed in late update):
foreach (var B in smRenderer.bones)
{
if (B.parent == null)
continue;
Debug.DrawLine(B.position, B.parent.position, Color.red);
}
This works fine.
Instead of using the bone parent position and the bone position, I’m trying to draw the bone by drawing a line with a start point of parent.position and an endpoint of:
endPoint = parent.position + bone.forward * (bone.position - parent.position).magnitude
It’s not working. Lines drawn are at the correct starting position, of course, but the direction is all wrong. I’ve also tried using bone rotation to no avail.
I guess a more concise way of putting it would be: How is a bone’s ‘position’ (world) property calculated? I assume it’s a function of the parent’s position/rotation and its own localPosition and localRotation (?)
Any ideas? Thank you.