Is there a way to get the size of a bone?
transform.localScale only returns values like 1
I want to get the size so I can generate a collision box the size of the bone.
Is there a way to get the size of a bone?
transform.localScale only returns values like 1
I want to get the size so I can generate a collision box the size of the bone.
I don’t think bones have a dimension such a size. They are just a hierarchy of transforms, which are points in space with a given orientation and offset and relation to other transforms.
Bones don’t really have a “size”, unless you’re looking for their scale value (which as you’ve found, is almost always 1 for most animations). If the value you’re looking for is, for example, “the length of this character’s forearm”, you can use wristBone.localPosition.magnitude, which will get the distance between the wrist and the elbow, which I’m guessing is what you want.
If you are talking about 2D then bones do have a length. See: Unity - Scripting API: U2D.SpriteBone.length
The docs even say, “This is important for the leaf bones to describe their length without needing another bone as the terminal bone.”
I am trying to figure out how to obtain this struct data myself.
@tonytopper did you found the way to use it? im trying to, unfortunately it always produce 0 value, even the color is 0, 0, 0, 0. how to use the struct ?
I never figured it out. Would be curious if folks manage to.
It was right next to in in the docs: https://docs.unity3d.com/ScriptReference/U2D.SpriteDataAccessExtensions.GetBones.html
Sorry, I did figure that part out. I wasn’t clear sorry. It was the question of the OP I never figured out. The length was always returning zero IIRC. Maybe it was a bug and was fixed. I haven’t looked.
Generate armature tree data, (if you use humanoid will be easier to use common data) And after that get Vector3.Distance between each bone.
Not best approach
At least it something)