• Editor
  • Bounding Box by name

Hi!

Polygon for name returns null:

SkeletonBounds skeletonBounds = new SkeletonBounds();
...
skeletonBounds.getPolygon(new BoundingBoxAttachment("bounding_left"))

how to get it in libGDX?

thanks!

P.S. i can only correctly obtain polygon with index

Related Discussions
...
BoundingBoxAttachment box = skeleton.getAttachment("slotName", "bboxName");
FloatArray polygon = skeletonBounds.getPolygon(box);

SkeletonBounds is for convenience doing hit detection. You don't need it to access the polygon, you can do:

BoundingBoxAttachment box = skeleton.getAttachment("slotName", "bboxName");
float polygon = new float[box.getVertices().length];
...
box.computeWorldVertices(skeleton.getX(), skeleton.getY(), slot.bone, polygon);
// use polygon

Thanks Nate!
works fine!

un an plus tard

And what does computeWorldVertices do?
Why do I call this method and how does it help me with hit detection?

I don't get it. 😢

The code is available, take a look. It transforms the bounding box vertices by the bone world transform. This is what makes the bounding boxes move with the bones.